I haven't written a blog for a long time, today to share with you how to use the MAVEN remote publishing app to Tomcat in Eclipse.
In general, we publish applications to the server need to now export the app into a war package, and then connect to the server to deploy the update, which is time-consuming and inconvenient, as a programmer to find the simplest way to handle similar application release of repetitive operations.
Maven is a very good organization package tool and we are now going to use MAVEN to implement remote publishing to the Tomcat server.
My Development Environment information:
maven:3.3.9
tomcat:8.0.35
First step: Configure the Tomcat role permissions information
Modify tomcat-users.xml
the file to add the following information to it (the user name password is subject to actual):
<RoleRolename="Manager"/><RoleRolename="Admin"/><Rolerolename= "Manager-gui"/><< Span class= "Hljs-title" >role rolename= "Manager-script"/ ><role rolename=" manager-jmx "/><role rolename= "manager-status"/> <user username= "admin" password= "admin123" roles= "Admin,manager,manager-gui,manager-script,manager-jmx,manager-status"/>
When the modifications are complete, launch and access the Tomcat test configuration to take effect.
Click the Manager App
button, enter the user information that you just configured in the popup dialog box, and then click the Login button to successfully log in as a successful configuration.
Step two: Modify MAVEN's setting.xml configuration file to add server information
<server> <id>devTomcat</id> <username>admin</username> <password>admin123</password></server>
The user name and password information in this will be the same as configured in the first step.
Step three: Open the MAVEN project pom.xml
file and add the following configuration to it
<Build><Plugins><Plugin><Groupid>org.codehaus.mojo</Groupid><Artifactid>tomcat-maven-plugin</Artifactid><version>1.1</version> < configuration> <url>http:// 172.20.6.169/manager/text</url> <server>devtomcat</server > <path>/dev</path> </configuration> </plugin> </ plugins> </BUILD>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
In this section of the configuration:
The URL is the remote Tomcat server address, in theory, the IP address can be replaced, the server is the MAVEN configuration file in the location of the servers Id,path for the application of the last published context path.
Fourth Step: Configure the Goals to: tomcat:redeploy
On the project, right-click, select, enter the value of goals in the Run As
Maven Build
popup dialog box tomcat:redeploy
, and then click the Run
button to start compiling the publication. This step after the configuration is complete, click again Maven Build
will compile the publication directly, the Hang difference console output information, the output shape as below the content is published successfully
[INFO] Deploying War to Http://172.20.6.169/dev
[INFO] Ok-deployed Application at Context Path/dev
[INFO] ————————————————————————
[INFO] BUILD SUCCESS
[INFO] ————————————————————————
[INFO] Total time:20.254 S
[INFO] Finished at:2016-10-09t16:05:16+08:00
[INFO] Final memory:14m/228m
[INFO] ————————————————————————
If the log outputs a 404 error, check that the URL configuration is correct, and if the output is 403 error, check that the Tomcat user role is configured correctly.
At this point, we have completed the configuration that was applied to tomcat through the MAVEN remote release.
Tips:
When compiling the Publish project, MAVEN may compile the test code causing the compilation to fail, and we can pom.xml
add the following configuration to skip the compilation of the test code
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skip>true</skip> </configuration></plugin>
Eclipse is applied to Tomcat via MAVEN remote publishing