maven tomcat7-maven-plugin配置及背景

时间:2023-03-09 09:17:03
maven tomcat7-maven-plugin配置及背景

背景:
在研发阶段,想让一个服务通过tomcat启动起来有很多的方法,常用的idea都有这样的支持,那么如果我们没有tomcat,能不能让服务通过tomcat启动起来呢?maven就提供了这样的支持。

maven-deploy-plugin配置使用:
其具体的配置示例如下:

<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<path>/</path> <!--指定路径-->
<port>8080</port> <!--指定端口 http:localhost:8080 如path包含具体的值如demo,则为: http:localhost:8080/demo-->
<contextFile>src/main/config/context.xml</contextFile>
<systemProperties>
<!--JAVA_OPTS设置在这里无效,必须设置环境变量MAVEN_DEBUG_OPTS
<JAVA_OPTS>-Xms256m -Xmx512m -XX:MaxPermSize=256m</JAVA_OPTS>
-->
<CONF_PATH>${project.basedir}/target/classes</CONF_PATH> <!--具体的打包后class路径-->
</systemProperties>
</configuration>
<dependencies>
<dependency> <!-- 可以指定相应的依赖,如无可忽略-->
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>${oracle.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>

那么如上就将maven插件简单的配置好了,那么启动命令就更简单了:mvn tomcat7:run 或mvn tomcat7:run -war 具体根据你的包结构所定。

如idea则可发现maven插件出现以下的控件列表:

maven tomcat7-maven-plugin配置及背景

其具体的相关参数请参考官网:http://tomcat.apache.org/maven-plugin-2.0/tomcat7-maven-plugin/usage.html