1. Open the Tomcat Manager feature in the Tomcat-users.xml folder
1 < role rolename = "Manager-gui" /> 2 rolename = "Manager-script" /> 3 username = "Tomcat" password = "Tomcat" roles = "Manager-gui,manager-script" />
2. Add in Pom.xml
1 <Build>2 <Finalname>ROOT</Finalname>3 <Plugins>4 <plugin>5 <groupId>Org.codehaus.mojo</groupId>6 <Artifactid>Tomcat-maven-plugin</Artifactid>7 <Configuration>8 <URL>Http://www.test.com:8080/manager</URL>9 <Server>Test</Server>Ten <Path>/</Path> One </Configuration> A </plugin> - </Plugins> - </Build>
View Code
Finalname is set to root here, so the MVN package generates a war file named Root.war, which actually doesn't matter what the name is.
The URL of the Tomcat manager that published the app is configured here, and the app is deployed to the root/bottom. However, the user name and password are not configured, and this is related to <server>test</server>. Here, the user name and password are configured in other external files, to avoid changes in different environments pom.xml.
3. Setting.xml under Maven
1 <?XML version= "1.0" encoding= "UTF-8"?>2 <Settings>3 <Servers>4 <Server>5 <ID>Test</ID>6 <username>Tomcat</username>7 <Password>123456</Password>8 </Server>9 </Servers>Ten </Settings>
View Code
4. Running
MVN Tomcat:deploy or
MVN Tomcat:redeploy
Deploy Web Apps to tomcat with Maven