maven3 + jetty 新建webapp

maven版本:apache-maven-3.3.3
eclipse插件版本:m2e - Maven Integration for Eclipse 1.4.1.20140328-1905


1. new-->maven project-->maven-archetype-webapp-->填写group_id,atifact_id-->finish
2. 创建完成后,结构如下
[img]http://dl2.iteye.com/upload/attachment/0110/5246/8c213a73-64bf-3940-9d53-6b19c3a3f6f8.jpg[/img]
3. 修改pom.xml,添加servlet dependency

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>


4. 添加maven的jetty插件

<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.8.v20150217</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<httpConnector>
<port>8081</port>
</httpConnector>

<webApp>
<contextPath>/${project.artifactId}</contextPath>
<!--
<resourceBases>
<resourceBase>${project.basedir}/src/main/webapp</resourceBase>
<resourceBase>${project.basedir}/commons</resourceBase>
</resourceBases>
-->
</webApp>

<requestLog implementation="org.eclipse.jetty.server.NCSARequestLog">
<filename>target/access-yyyy_mm_dd.log</filename>
<filenameDateFormat>yyyy_MM_dd</filenameDateFormat>
<logDateFormat>yyyy-MM-dd HH:mm:ss</logDateFormat>
<logTimeZone>GMT+8:00</logTimeZone>
<append>true</append>
<logServer>true</logServer>
<retainDays>120</retainDays>
<logCookies>true</logCookies>
</requestLog>
</configuration>
</plugin>
</plugins>


5.通过maven启动jetty
[img]http://dl2.iteye.com/upload/attachment/0110/5257/5ab51a1b-0cca-30ca-83ae-254aeb661334.jpg[/img]

6.访问 http://localhost:8081/springMybatis/
Hello World!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值