Requirements: Use maven to implement tomcat hot deployment, and deploy the project when Tomcat starts.
Principle: Tomcat has a background management function, which can realize hot deployment of projects.
1. Configuration method :
1. Deploying the project to the server first needs a tomcat service. We first unzip a tomcat on the server and name it tomcat-xxx:
2, start tomcat, view the boot log, web access:
1) Start command: /usr/app/tomcat-e3mall/bin/startup.sh
(found in the bin directory under your start.sh Tomcat)
2) view the log: tail -f /usr/app/tomcat-e3mall/logs/catalina.out
3) Access management interface prompts the user name and password
the first step : Need to modify the tomcat conf/tomcat-users.xml configuration file. Add user name, password, and permissions.
<role rolename="manager-gui" />
<role rolename="manager-script" />
<user username="tomcat" password="tomcat" roles="manager-gui, manager-script"/>
Step 2: Restart tomcat.
Second, the configuration of the pom file :
Use maven's tomcat plug-in to achieve hot deployment: the
first step: configure the tomcat plug-in, you need to modify the project's pom file.
<!-- 配置tomcat插件 -->
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<path>/</path>
<port>8080</port>
<!-- maven方式tomcat热部署 -->
<url>http://192.168.113.110:8080/manager/text</url>
<username>tomcat</username>
<password>tomcat</password>
</configuration>
</plugin>
</plugins>
</build>
Step 2: Use the maven command to deploy.
tomcat7:deploy #首次发布
tomcat7:redeploy #再次发布(通常是再次)
The deployment path is "/" and the system will be deployed to the webapps/ROOT directory.
The deployment project skips the test:
clean tomcat7:redeploy -DskipTests
Verify the deployment of the project :
1. Use dubbo-admin's service management to check whether there is a service (recommended);
2. Check whether the "/" Running under the page you visit http://ip number:8080/manager/html is "true" ";
Question: What is the reason why the project published to tomcat is not started?
Solution: 1. Check whether the local jdk version is inconsistent with the server jdk version, (here is local java1.8, remotely forgot to install 1.7);
2. Check whether the jar package conflicts during release; (I haven’t encountered it for the time being To, so tentatively)