一、通过外部tomcat
运行方式
二、通过内部Jettty
在maven的pom中加入如下
<build>
<plugins>
<!-- jetty插件 -->
<!--通过 maven run-->
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.25</version>
<configuration>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<!--监听端口-->
<port>8000</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
<!--应用的上下文设置,若不设置则默认用 artifactId 的名称-->
<contextPath>/bbs</contextPath>
<!--自动热部署 0表示禁用 大于0表示开启 单位为秒-->
<scanIntervalSeconds>0</scanIntervalSeconds>
<!--可以指向一个备选的web.xml 默认是 WEB-INF下面的web.xml-->
<!--<overrideWebXml>src/main/webapp/WEB-INF/web.xml</overrideWebXml>-->
<!--允许用户设置一个插件执行操作时配置系统属性-->
<systemProperties>
<systemProperty>
<name>org.apache.commons.logging.Log</name>
<value>org.apache.commons.logging.impl.SimpleLog</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>
<!--用户执行单元测试的 比如:mvn test或mvn surefire:test 生成测试报告 会生成在:${basedir}/target/surefire-reports
跳过测试可以 mvn clean package -Dmaven.test.skip=true
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<!--true为跳过测试运行-->
<skipTests>true</skipTests>
<parallel>methods</parallel>
<threadCount>10</threadCount>
</configuration>
</plugin>
</plugins>
</build>
运行方式:
1.通过idea右边的maven
2.通过 运行maven命令
mvn jetty:run