maven remote deployment project

Overview:

        In development, there is often a test server for the project team to deploy the project for testing. So here comes the problem. How does everyone deploy the project to this test server? , if your project happens to use Maven, the following content is your dish. go go go 

 

Ring mirror description:

linux:centos6

tomcat:7.0.57

jdk:1.6.45

 

Step 1: Add tomcat7-maven-plugin to the POM file that needs to be installed in the project

            <!--Remote deployment to TOMCAT debugging-->
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <url>http://192.168.1.174:80/manager/text</url>
                    <server>api-server</server>
                    <uriEncoding>UTF-8</uriEncoding>
                    <path>/api</path>
                </configuration>
            </plugin>

 Part 2: In order to download the required tomcat7-maven-plugin correctly, configure the following content in the POM file (if it is a multi-module project, configure it in the parent's POM)

    2.1 Add under the repositorys node:

        <repository>
            <id>people.apache.snapshots</id>
            <url>http://repository.apache.org/content/groups/snapshots-group/</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>

    2.2 Add under the pluginRepositories node:

    <pluginRepositories>
        <pluginRepository>
            <id>apache.snapshots</id>
            <name>Apache Snapshots</name>
            <url>
                http://repository.apache.org/content/groups/snapshots-group/
            </url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

 Step 3: Add the server node to the maven setting.xml file

<servers>  
  <server>
      <id>api-server</id>
      <username>admin</username>
      <password>admin</password>
    </server>
  </servers>

   Note: The value of <id> corresponds to the value of <server> in the first step, and <sername> and <password> are the usernames used to log in to tomcat. So the next step is to configure tomcat.

Step 4: Configure Tomcat on the test server and configure the following in tomcat-users.xml

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

 Note: The user name and password configured here need to be the same as the third step.

Step 5: Start tomcat (Note: If you want to publish the service now, you can't connect if the service is not started)

Step 6: Publish the project

tomcat7:deploy

 There are many commands in tomcat7-maven-plugin, you can find the usage by yourself. I use IDEA to publish it here, which is very convenient:

 

If the publishing is all right, then it's ready to be accessed through the browser. You don't need to restart Tomcat yourself. Tomcat supports hot deployment.

 

Problems encountered:

1:OutOfMemoryError: PermGen space (this problem is because the default permanent generation of tomcat is too small

Solution: Modify the JVM startup parameters of tomcat (tomca/bin/catalina.sh) before cygwin= false

JAVA_OPTS="-Xms256m-Xmx512m -Xss1024K-XX:PermSize=128m-XX:MaxPermSize=256m"

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326496221&siteId=291194637