tomcat + maven 自动部署

时间:2022-05-31 06:05:10

1. 工程的pom.xml指定server名称

<plugins>
    /* ... */
    <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.2</version>
        <configuration>
            <url>http://localhost:8080/manager/text</url>
            <server>tomcat7</server>
            <path>/${project.build.finalName}</path>
            <uriEncoding>UTF-8</uriEncoding>
        </configuration>
    </plugin>
</plugins>

 

2. tomcat-users.xml

<tomcat-users>
  <user username="test" password="tomcat" roles="tomcat,manager-script,manager-gui"/>
</tomcat-users>

 

3. maven/conf/settings.xml

  <servers>
    <server>
      <id>tomcat7</id>
      <username>test</username>
      <password>tomcat</password>
    </server>
  </servers>

 

4. mvn tomcat7:deploy