Deploy the local project to the local tomcat server

Some simple solutions are as follows:
1: Download the tomcat package from the Internet and put it in a specified path.
1) Start tomcat. If Chinese garbled characters appear in the console output, modify: java.util.logging.ConsoleHandler.encoding = GBK in D: \ apache-tomcat-8.5.45 \ conf \ logging.properties file (original here The attribute value is UTF-8)
2) If you deploy to the project in tomcat, the project appears Chinese garbled, then modify: D: \ apache-tomcat-8.5.45 \ bin \ catalina.bat in the Insert picture description here
picture as shown , Add this line of code under setlocal: set JAVA_OPTS = -Dfile.encoding = UTF8, so that the Chinese garbled problem in the project is solved.

2: The IDEA tool I use, the springboot used by the project framework, the persistence layer framework is mybatis, the database uses mysql, and the project is packaged as a war package to the tomcat server. Insert picture description here
As shown in the figure, in the IDEA tool, click MAVEN on the right, pop-up window pop-up box, first click clean, then click package or install, wait for the project to be marked as a war package, after the end, the console will output the location of the war, in fact this The location is generally under the target folder in the project file. Note that the war package must be modified in the pom.xml file, as shown in the figure: set to war in the packaging tab. Insert picture description here
Insert picture description here
In the build tag, you can set the name of the war package, and set the name of the war package in finalName.

3: Put the war package into the webapps folder in the tomcat server. Start the server, wait for the console to run, open the browser, if the project setting port number is the default port 8080 of tomcat, then the access path is
http: // localhost: 8080 / project name / the normal access path of the project. For example:
http: // localhost: 8080 / Dam / test / index Dam like this is the name of the project in webapps, test / index is the path to access the controller.
This will give you access to the initial page of the project you want to visit.

4: Implement the access path to remove the project name: In tomcat, open the D: \ apache-tomcat-8.5.45 \ conf \ server.xml file, find the tag, add a sub-tag in this tag, and the content is as follows: Insert picture description here
where the docBase attribute The added value is the / project name. The Insert picture description here
overall picture is as shown above. After this setting, re-place the war package in webapps and run. You may get an error. If the error is reported, then you need to set a line of code in the project's configuration file: application Add the following line of code to the .properties file:

# 这个是用于将项目部署到tomcat中去,去掉项目名访问的时候,避免报错
spring.jmx.enabled=false

This redeployment will not report an error when starting tomcat, and then the access path may be the same as the original for the first time, and then restart the tomcat server for the second time, the access path can remove the project name, http: // localhost: 8080 / test / index

In this way, the project is simply deployed to tomcat and run on the local server. Next, I want to record, if you deploy the project to a remote server, and how to configure the project to achieve a direct domain name, you can access the initial page of the project you want to visit, see follow-up ...

Published 13 original articles · Like1 · Visit 2006

Guess you like

Origin blog.csdn.net/qq_31152023/article/details/100651425