Preface
This article mainly introduces to you the relevant content about maven using the tomcat plug-in to deploy remote Linux servers. We will share it for your reference and learning. I won’t say much below, let’s take a look at the detailed introduction.
environment
Server: Ubuntu 16.04 (Ali Cloud Server)
jdk version: 1.8
Related maven plugins:
The purpose of this plugin is to skip tests when deploying
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.18.1</version> <configuration> <skipTests>true</skipTests> </configuration></plugin> tomcat plugin<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <path>/myweb</path> <port>80</port> <uriEncoding>UTF-8</uriEncoding> <url>http://XXXXX/manager/text</url> <!-- /manager/text here is a must, and the front is your host. For example, http://localhost/manager/text --> <username>XXXX</username> <!-- The account used for remote login will be mentioned later --> <password>XXXX</password> <!-- The password used for remote login will be mentioned later --> <update>true</update> </configuration></plugin>
1. First of all, you need to create a remote user under conf/tomcat-users.xml
For example
<role rolename="manager-gui"/><role rolename="manager-script"/><user username="XXXX" password="XXXX" roles="manager-gui,manager-script" />
username and password correspond to the above <username>XXXX</username> <password>XXXX</password> .
2. Tomcat can only be accessed by the same physical machine by default. Therefore, if only the above is equipped, it still cannot be deployed remotely, and an error of 401 will be reported. You need to create manager.xml under conf/Catalina/localhost/. Specifies access rules that allow remote physical machines. Here is a template, manager.xml will allow any physical machine to access
<Context privileged="true" antiResourceLocking="false" docBase="${catalina.home}/webapps/manager"> <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="^.*$" /></Context>Note that the allow property of the <value/> node, which is a regular expression, is used to match the IP of the remote connection.
In this way, you can use maven to deploy remotely
Next, a dialog box will pop up when logging in to http://xxxxx/manage, enter the remote login user and password.
References:
https://stackoverflow.com/que...
https://stackoverflow.com/que...
Summarize
The above is the entire content of this article. I hope that the content of this article has certain reference value for everyone's study or work. If you have any questions, you can leave a message to communicate. Thank you for your support to Wulin.com.