站内搜索:
首页 >> 前端 >> 内容
maven jetty plugin

时间:2013/5/24 14:59:14

 


TIPS ==============


mvn jetty:run, 自动运行,使用的class在 /target/classes, 使用的webapp在 src/main/webapp, 使用的web.xml在 src/main/webapp/WEB-INF/web.xml
启动后,自动监听加载文件变化情况,可在eclipse中边改,边测试
通过如下配置,可在集成测试时自动启动和停止
[html]  <executions> 
               <execution> 
                       <id>start-jetty</id> 
                       <phase>pre-integration-test</phase> 执行期间> 
                       <goals> 
                               <goal>run</goal> 执行目标 
                        </goals> 
                       <configuration> 
                               <scanIntervalSeconds>0</scanIntervalSeconds> 
                               <daemon>true</daemon> 
                       </configuration> 
               </execution> 
               <execution> 
                       <id>stop-jetty</id> 
                       <phase>post-integration-test</phase> 
                       <goals> 
                               <goal>stop</goal> 
                       </goals> 
               </execution> 
       </executions> 

 <executions>
                <execution>
                        <id>start-jetty</id>
                        <phase>pre-integration-test</phase> 执行期间>
                        <goals>
                                <goal>run</goal> 执行目标
                         </goals>
                        <configuration>
                                <scanIntervalSeconds>0</scanIntervalSeconds>
                                <daemon>true</daemon>
                        </configuration>
                </execution>
                <execution>
                        <id>stop-jetty</id>
                        <phase>post-integration-test</phase>
                        <goals>
                                <goal>stop</goal>
                        </goals>
                </execution>
        </executions>


[html]  端口、root等配置: 
 
                <configuration> 
 
          <contextpath>/</contextpath> 
 
          <connectors> 
 
            <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector"> 
 
              <port>8080</port> 
 
              <maxidletime>60000</maxidletime> 
 
            </connector> 
 
          </connectors> 
 
          <scanintervalseconds>10</scanintervalseconds>//资源文件变动的扫描时间 
 
          <webdefaultxml>src/main/resources/webdefault.xml</webdefaultxml> // 此文件替换 src/webapp/WEB-INF/web.xml 
 
          <webappsourcedirectory>${basedir}/src/staticfiles</webappsourcedirectory> // default is src/webapp 
 
          <webxml>${basedir}/src/over/here/web.xml</webxml> // default is src/webapp/WEB-INF/web.xml 
 
          <classesdirectory>${basedir}/somewhere/else</classesdirectory> // default is target/classes/ 
 
        </configuration> 

端口、root等配置:

                <configuration>

    <contextpath>/</contextpath>

    <connectors>

      <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">

        <port>8080</port>

        <maxidletime>60000</maxidletime>

      </connector>

    </connectors>

    <scanintervalseconds>10</scanintervalseconds>//资源文件变动的扫描时间

    <webdefaultxml>src/main/resources/webdefault.xml</webdefaultxml> // 此文件替换 src/webapp/WEB-INF/web.xml

    <webappsourcedirectory>${basedir}/src/staticfiles</webappsourcedirectory> // default is src/webapp

    <webxml>${basedir}/src/over/here/web.xml</webxml> // default is src/webapp/WEB-INF/web.xml

    <classesdirectory>${basedir}/somewhere/else</classesdirectory> // default is target/classes/

  </configuration>


或者通过命令参数指定: mvn -D jetty.port=9999 jetty:run
mvn jetty:run-war , mvn jetty:deploy-war 默认运行 ${project.build.directory}/${project.build.finalName}.war, 不同在于, jetty:deploy-war不会触发编译,测试等mvn周期

 

  • 上一篇:做淘宝网页设计师你需要具备哪些素质
  • 下一篇:教你挑选最适合自己的CMS
  • 返回顶部