您的位置:首页 > 其它

maven之jetty-maven-plugin插件

2016-01-28 20:15 232 查看
在各种学习体验和项目实战中,发现jetty比tomcat在开发方面更加的方便和好用,所以,下面就留下我的笔记,这个例子的代码还是接着上面的maven搭建的例子,jetty在maven中的使用方法如下:

步骤一:

在tian-parent中的插件管理中添加:

<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.7.v20160115</version>
<configuration>
<webApp>
<contextPath>/hello</contextPath>
</webApp>
<scanIntervalSeconds>10</scanIntervalSeconds>
<stopPort>9899</stopPort>
<stopKey>foo</stopKey>
<stopWait>10</stopWait>
<systemProperties>
<systemProperty>
<name>tapestry.execution-mode</name>
<value>development</value>
</systemProperty>
<systemProperty>
<name>jetty.port</name>
<value>9090</value>
</systemProperty>
</systemProperties>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>


步骤二:

在tian-web中的插件中加入:

<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
</plugin>


在tian-web的pom.xml中运行clean package jetty:run就会在控制台看到jetty已经启动,

在浏览器中输入你配置的路径,比如本实例,我配置的是
http://127.0.0.1:9090/hello/HelloServlet


就可以看到我的网页结果了,jetty可以配置一个检查更新的比如10s等,不用我们再去手动的打包编译等动作,这个就比tomcat的方便多了。



在我的配置过程中,也是出现了好多错误,真心感觉百度简直就是恶心人,大家想办法翻墙Google吧,花费了n天再次体会到技术的东西,百度跟谷歌的差距不是用时间就能解决的。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: