Home‎ > ‎Maven‎ > ‎Plugins‎ > ‎

Tomcat

Auto deploying to the Apache Tomcat7 manager.

Reference

Auto Deploy

Tomcat Server Configuration

Simply deploy your application by configuring the Tomcat plugin to deploy to the Tomcat7 manager.

1. First Edito the /etc/tomcat7/tomcat-users.xml file.
sudo nano /etc/tomcat7/tomcadt-users.xml
2. Add a user with manager-script permission.
<tomcat-users>
   
<role rolename="admin-gui"/>
   
<role rolename="admin-script"/>
   
<role rolename="manager-gui"/>
   
<role rolename="manager-script"/>
   
<role rolename="manager-jmx"/>
   
<role rolename="manager-status"/>

   
<user username="maven" password="deployPass" roles="manager-script"/>
</tomcat-users>
3. Edit the maven settings.xml
sudo nano ~/.m2/settings.xml
4. And in that settings.xml servers element add:
<server>
   
<id>maven-tomcat</id>
   
<username>maven</username>
   
<password>deployPass</password>
</server>

Maven Tomcat Plugin Configuration

1. Put these properties in the pom.xml
<properties>
     
<tomcat.path>/appPath</tomcat.path>
     
<tomcat.server.url>http://domain.com/manager/text</tomcat.server.url>
     
<tomcat-maven-plugin.version>2.0</tomcat-maven-plugin.version>
</properties>
2. Add the Tomcat7 plugin for deploying to the Tomcat manager.
  • To use the manager from maven the path will need to have /text appended to it for it to work properly.
<!-- Tomcat deployment configuration -->
<!-- run 'mvn clean deploy' -->
<!-- run 'mvn tomcat7:deploy -DskipTests -X' debug deploy -->
<plugin>
   
<groupId>org.apache.tomcat.maven</groupId>
   
<artifactId>tomcat7-maven-plugin</artifactId>
   
<version>${tomcat-maven-plugin.version}</version>
   
<configuration>
       
<!-- add the security credentials to ~/.m2/settings.xml <id>...</id> -->
       
<server>maven-tomcat</server>
       
<path>${tomcat.path}</path>
       
<url>${tomcat.server.url}</url>
       
<update>true</update>
   
</configuration>
   
<executions>
       
<execution>
           
<phase>deploy</phase>
           
<goals>
               
<goal>deploy</goal>
           
</goals>
       
</execution>
   
</executions>
</plugin>

3. To deploy run 'mvn cleandeploy'.
  • To skip building but upload the war, run 'mvn tomcat7:deploy'.
































Comments