最近一个小项目是使用maven开发的运行在jetty容器里的项目,现将一些经验总结如下:
1、eclipse有强大的run jetty run插件支持,简单可行。
2、既然使用了maven,在原来的pom文件里也有相应的插件。索性就直接使用集成的jetty吧,命令执行:
mvn clean jetty:run
启动容器正常,项目运行正常。
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.1.v20120215</version>
<configuration>
<stopKey>stop</stopKey>
<stopPort>5599</stopPort>
<webAppConfig>
<contextPath>/</contextPath>
</webAppConfig>
<scanIntervalSeconds>0</scanIntervalSeconds>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>8886</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
</configuration>
</plugin>
</plugins>