Maven提供将web项目部署到servlet容器上运行的方式,如果我们不使用这种方式,需要先执行maven的install命令,将web项目打包成war包,然后拷贝到servlet容器中webapps下启动运行
项目右键maven install 之后,项目就启动起来了。
tips:在ide工具中无法停止servlet容器服务,端口也一直被占用,只能去tomcat/bin下手动将服务kill。
提供的ctrl+c停止服务的方式是在命令行下才有效果
<!-- 配置当前模块构建过程中的特殊设置 -->
<build>
<finalName>controllerMvn</finalName>
<!-- 配置构建过程中需要使用的插件 -->
<plugins>
<plugin>
<!-- cargo是一个专门启动servlet容器(jboss,weblogic,tomcat..)的组织 -->
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.2.3</version>
<!-- 针对插件进行配置 -->
<configuration>
<!-- 配置当前系统中容器的位置 -->
<container>
<containerId>tomcat7x</containerId>
<home>E:\apache-tomcat-7.0.59</home>
</container>
<configuration>
<type>existing</type>
<home>E:\apache-tomcat-7.0.59</home>
<!-- 如果Tomcat端口为默认值8080则不必设置该属性 -->
<properties>
<cargo.servlet.port>8989</cargo.servlet.port>
</properties>
</configuration>
</configuration>
<!-- 配置插件在什么情况下执行 -->
<executions>
<execution>
<id>cargo-run</id>
<!-- 生命周期的阶段 -->
<phase>install</phase>
<goals>
<!-- 插件的目标 -->
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>