deploy spring war to tomcat.

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,

< role rolename = "manager" />
< role rolename = "manager-gui" />
< role rolename = "admin" />
< user username = "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 package tomcat7:deploy

Troubleshooting

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

你可能感兴趣的:(deploy spring war to tomcat.)