maven版本3.0.5
jdk 1.7
jetty-maven-plugin 9.2.18
pom.xml 配置:
<build> <plugins> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>9.2.18.v20160721</version> <configuration> <httpConnector> <port>8088</port> </httpConnector> <scanIntervalSeconds>5</scanIntervalSeconds> <stopKey>foo</stopKey> <stopPort>9999</stopPort> <webApp> <contextPath>/user-web</contextPath> </webApp> </configuration> <executions> <execution> <id>start jetty</id> <phase>pre-integration-test</phase> <goals><goal>start</goal></goals> <configuration> <scanIntervalSeconds>0</scanIntervalSeconds> </configuration> </execution> <execution> <id>stop jetty</id> <phase>post-integration-test</phase> <goals> <goal>stop</goal> </goals> </execution> </executions> </plugin> </plugins> </build> 配好之后 使用 jetty:run 启动成功。
注意如果不同的版本的jetty 可能需要不同版本的JDK 和 maven版本, 有错可以从这些方面入手。。。。。。。
当然最好是参照jetty官网 这样不容易出错
https://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html#jetty-run-goal