Jetty与Maven集成
在项目中为了方便起见需要把服务器集成到Maven中以方便调试,
作为plugin集成:
[html]
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webAppConfig>
<contextPath>/web</contextPath>
<!-- 额外的ClassPath配置,路N多的properties文件等 -->
<extraClasspath>properties</extraClasspath>
</webAppConfig>
<contextHandlers>
<!-- 子项目依赖,或者需要加多个项目到这一个jetty运行环境里面 -->
<contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
<war>../subweb/src/main/webapp</war>
<contextPath>/subweb</contextPath>
</contextHandler>
</contextHandlers>
<systemProperties>
<systemProperty>
<name>catalina.base</name>
<value>${basedir}/target</>
</systemProperty>
</systemProperties>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>8080</port>
<maxIdleTime>400000</maxIdleTime>
</connector>
</connectors>
</configuration>
</plugin>
直接在项目下运行mvn jetty:run
作为Maven参数集成:
[html]
<profiles>
<profile>
<id>run-jetty</id>
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webAppConfig>
<contextPath>/web</contextPath>
<extraClasspath>properties</extraClasspath>
</webAppConfig>
<contextHandlers>
<contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
<war>../subweb/src/main/webapp</war>
<contextPath>/subweb</contextPath>
</contextHandler>
</contextHandlers>
<systemProperties>
<systemProperty>
<name>catalina.base</name>
<value>${basedir}/target</>
</systemProperty>
</systemProperties>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>8080</port>
<maxIdleTime>400000</maxIdleTime>
</connector>
</connectors>
</configuration>
</plugin>
</plugins>
</build>
<profile>
<profiles> www.2cto.com
项目下运行 mvn -DskipTests=true clean test -Prun-jetty
http://www.devhup.com/?p=140
作者:devhubs下一篇: flask框架实现修改密码和免密登录功能