Eclipse Maven Jetty集成

1、添加项目


2、选择maven-archetype-webapp



3、添加公司/组织名称,项目名称,版本号



4、补全未生成的文件夹


5、pom.xml中添加jetty插件信息

[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. <plugins>  
  2.     <plugin>  
  3.         <groupId>org.mortbay.jetty</groupId>  
  4.         <artifactId>maven-jetty-plugin</artifactId>  
  5.         <version>6.1.9</version>  
  6.         <configuration>  
  7.             <scanIntervalSeconds>10</scanIntervalSeconds>  
  8.             <stopKey>foo</stopKey>  
  9.             <stopPort>9999</stopPort>  
  10.         </configuration>  
  11.         <executions>  
  12.             <execution>  
  13.                 <id>start-jetty</id>  
  14.                 <phase>pre-integration-test</phase>  
  15.                 <goals>  
  16.                     <goal>run</goal>  
  17.                 </goals>  
  18.                 <configuration>  
  19.                     <scanIntervalSeconds>0</scanIntervalSeconds>  
  20.                     <daemon>true</daemon>  
  21.                 </configuration>  
  22.             </execution>  
  23.             <execution>  
  24.                 <id>stop-jetty</id>  
  25.                 <phase>post-integration-test</phase>  
  26.                 <goals>  
  27.                     <goal>stop</goal>  
  28.                 </goals>  
  29.             </execution>  
  30.         </executions>  
  31.     </plugin>  
  32. </plugins>  


6、执行 mvn jett:run

[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. D:\workspace201408\sshdemo>mvn jetty:run  
  2. [INFO] Scanning for projects...  
  3. [INFO]  
  4. [INFO] ------------------------------------------------------------------------  
  5. [INFO] Building sshdemo Maven Webapp 0.0.1-SNAPSHOT  
  6. [INFO] ------------------------------------------------------------------------  
  7. [INFO]  
  8. [INFO] >>> maven-jetty-plugin:6.1.9:run (default-cli) > test-compile @ sshdemo >>>  
  9. [INFO]  
  10. [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ sshdemo ---  
  11. [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!  
  12. [INFO] Copying 0 resource  
  13. [INFO]  
  14. [INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ sshdemo ---  
  15. [INFO] Nothing to compile - all classes are up to date  
  16. [INFO]  
  17. [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ sshdemo ---  
  18. [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!  
  19. [INFO] skip non existing resourceDirectory D:\workspace201408\sshdemo\src\test\resources  
  20. [INFO]  
  21. [INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ sshdemo ---  
  22. [INFO] Nothing to compile - all classes are up to date  
  23. [INFO]  
  24. [INFO] <<< maven-jetty-plugin:6.1.9:run (default-cli) < test-compile @ sshdemo <<<  
  25. [INFO]  
  26. [INFO] --- maven-jetty-plugin:6.1.9:run (default-cli) @ sshdemo ---  
  27. [INFO] Configuring Jetty for project: sshdemo Maven Webapp  
  28. [INFO] Webapp source directory = D:\workspace201408\sshdemo\src\main\webapp  
  29. [INFO] web.xml file = D:\workspace201408\sshdemo\src\main\webapp\WEB-INF\web.xml  
  30. [INFO] Classes = D:\workspace201408\sshdemo\target\classes  
  31. [INFO] Logging to org.slf4j.impl.SimpleLogger(org.mortbay.log) via org.mortbay.log.Slf4jLog  
  32. [INFO] Context path = /sshdemo  
  33. [INFO] Tmp directory =  determined at runtime  
  34. [INFO] Web defaults = org/mortbay/jetty/webapp/webdefault.xml  
  35. [INFO] Web overrides =  none  
  36. [INFO] Webapp directory = D:\workspace201408\sshdemo\src\main\webapp  
  37. [INFO] Starting jetty 6.1.9 ...  
  38. [INFO] jetty-6.1.9  
  39. [INFO] No Transaction manager found - if your webapp requires one, please configure one.  
  40. [INFO] Started SelectChannelConnector@0.0.0.0:8080  
  41. [INFO] Started Jetty Server  


7、访问http://localhost:8080/sshdemo/

以上过程是最简单的eclipse + jetty + maven实现一个小的web项目,当然这里jetty其实是一个轻量级的web容器,和tomcat类似。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值