25/09/2013

Remote deploy Tomcat application using Maven

Configure Tomcat servers for Maven:

Open ~/.m2/settings.xml (if it doesn't exist, create it), add the following lines:
  <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
      <!-- Omit the irrelevant information here -->
      <server>
        <id>Tomcat7</id>
        <username>tomcat</username>
       <!-- Change this password -->
        <password>mypassword</password>
      </server>
     <!-- Omit the irrelevant information here -->
  </servers>
</settings>


Configure pom.xml:

Add the plugin for Maven:

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>tomcat-maven-plugin</artifactId>
             <version>1.1</version>
            <configuration>
                <server>Tomcat7</server>
                <!-- Change the name of your server -->
                <url>http://example.com:8080/manager/text</url>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <packagingExcludes>WEB-INF/web.xml</packagingExcludes>
            </configuration>
 </plugin>
                


Configure Tomcat:

Open file /conf/tomcat-users.xml:


   <tomcat-users>
   <role rolename="manager-gui"/>
   <role rolename="manager-script"/>
   <user username="tomcat" password="mypassword" roles="manager-gui,manager-script"/>
</tomcat-users>
   
   


Using:

Run your application with goal tomcat:redeploy the application will be redeployed to remote server.


Bài viết liên quan



Không có nhận xét nào:

Đăng nhận xét