Maven项目使用Tomcat插件发布

tomcat7-maven-plugin 插件使用

在pom.xml的plugins节点下添加下面代码,插件官网 http://tomcat.apache.org/maven-plugin.html

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <path>/</path>
        <port>8080</port>
        <server>tomcat7</server>
    </configuration>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
</plugin>

插件对应的命令如下

  • tomcat7:deploy部署一个web war包
  • tomcat7:reload重新加载web war包
  • tomcat7:start启动tomcat
  • tomcat7:stop停止tomcat
  • tomcat7:undeploy停止一个war包
  • tomcat7:run启动嵌入式tomcat ,并运行当前项目