This article will explain on how to deploy a war fine in to Tomcat 7 through maven build.
Note : I have tested same settings for Tomcat 8 as well. So below settings can be apply for both versions.
Note : I have tested same settings for Tomcat 8 as well. So below settings can be apply for both versions.
- Configure tomcat7-maven-plugin in pom.xml
<!-- Tomcat plugin --> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <path>/${project.build.finalName}</path> <update>true</update> <url>http:// localhost:8080/manager/text</url> <username>tomcat</username> <password>tomcatuser</password> </configuration> </plugin>
- Configure user rights in the tomcat-user.xml which is in the tomcat conf file.
<role rolename="tomcat" /> <role rolename="manager-gui" /> <role rolename="manager-script" /> <role rolename="admin-gui" /> <user username="tomcat" password="tomcatuser" roles="tomcat,manager-gui,admin-gui,manager-script" />
- Once above steps are followed, You can deploy the war by running following maven goal
mvn tomcat7:redeploy
More details of the Apache Tomcat Maven Plugin refer maven-plugin-2.2