公司使用maven构建项目,之前并没有在项目中实际用到maven,因此需要重新搭建开发环境,记录下来过程:
1.右键项目debug as添加mvn命令: jetty:run
2.进入eclipse的菜单Run->Debug configurations,会看到maven build下对应的项目的mvn命令的项,选中Environment选项卡 -->New,name输入MAVEN_OPTS,value中加入-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=y
3.项目右键Debug as-->Maven build(刚才设置的mvn命令)
maven下 jetty:run很爽,但是偶尔想通过eclipse调式一下可以吗?
回答是肯定的
Goals还是设置为jetty:run
Environment添加variable
name:MAVEN_OPTS
variable:-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
然后eclipse debug,跟以前一样调试有木有
?
以上转自:http://www.spasvo.com/ceshi/open/kydycsgj/junit/2013121293531.html
?
?
按照上面的步骤进行操作可以使用jetty 启动项目,并且可以debug,实现热部署。
以下为pom中相关的插件信息
<plugin>
? ? ? ? ? ? ? ? <groupId>org.mortbay.jetty</groupId>
? ? ? ? ? ? ? ? <artifactId>maven-jetty-plugin</artifactId>
? ? ? ? ? ? ? ? <version>6.1.25</version>
? ? ? ? ? ? ? ? <configuration>
? ? ? ? ? ? ? ? ? ? <scanIntervalSeconds>10</scanIntervalSeconds>
? ? ? ? ? ? ? ? ? ? <stopKey>foo</stopKey>
? ? ? ? ? ? ? ? ? ? <stopPort>9999</stopPort>
? ? ? ? ? ? ? ? ? ? <connectors>
? ? ? ? ? ? ? ? ? ? ? ? <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
? ? ? ? ? ? ? ? ? ? ? ? ? ? <port>80</port>
? ? ? ? ? ? ? ? ? ? ? ? </connector>
? ? ? ? ? ? ? ? ? ? </connectors>
? ? ? ? ? ? ? ? ? ? <webAppConfig>
? ? ? ? ? ? ? ? ? ? ? ? <contextPath>/</contextPath>
? ? ? ? ? ? ? ? ? ? </webAppConfig>
? ? ? ? ? ? ? ? </configuration>
?
? ? ? ? ? ? ? ? <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>
? ? ? ? ? ? </plugin>