deploy spring war to tomcat.

来源:互联网 发布:mysql实时同步数据库 编辑:程序博客网 时间:2024/04/26 11:18
omcat7 deployment can be automated from Maven using tomcat7-maven-plugin, http://tomcat.apache.org/maven-plugin-2.0-SNAPSHOT/tomcat7-maven-plugin/plugin-info.html.  To enable Tomcat deployment, do the following,
  • Configure Tomcat7
  • Add plugin to pom.xml 
  • Invoke tomcat7:deploy
  • Troubleshooting

Configure Tomcat7

Edit conf/tomcat-users.xml, and append the following,

<rolerolename="manager"/>
<rolerolename="manager-gui"/>
<rolerolename="admin"/>
<userusername="admin"password="admin"roles="admin,manager,manager-gui"/>

Add plugin to pom.xml 

<pluginRepositories>
 
....
    <pluginRepository>
        <id>apache.snapshots</id>
        <name>Apache Snapshots</name>
        <url>http://people.apache.org/repo/m2-snapshot-repository</url>
        <releases>
            <enabled>false</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
 
....
</pluginRepositories>
 
 
<build>
<plugins>
....
<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.0-SNAPSHOT</version>
    <configuration>
        <username>admin</username>
        <password>admin</password>
        <update>true</update>
    </configuration>
</plugin>
 
....
</plugins>
</build>

Invoke tomcat7:deploy

Add a Run As profile for your Maven build with the following,

clean packagetomcat7:deploy

Troubleshooting

403 forbidden error: make sure you use tomcat7 not tomcat  (some default value such as <url> has changed in Tomcat 7)
原创粉丝点击