I have not experienced manual packaging and deployment under WebApps server Tomcat before

clean install

Then he started to pit


First, step on the pit scene


Prerequisite: Manually package the project into a WAR package and place it under WebApps. Tomcat starts the automatic decompression successfully

The path to the webapps project localhost:8080/wechat/wx is correct, but the 404 resource does not exist


Answers from other blogs, turn off the firewall, change tomcat/conf/web.xml, JDK version (I think it might have an impact, I changed the JDK11 on the server to be the same as the JDK8 specified by the project from the beginning)…….


Another blog says that if the path and configuration of the server are OK, then it’s not the server’s fault (yes, most likely the configuration of your project is wrong), it’s the project itself, back to local, local works perfectly. Recall that in your Application. YML configuration file, the connection to the JDBC database is local, and MySQL is not installed on the server, possibly so that the project may not have been started at all on the server, and then access resources do not exist

That’s it, and I’m going to go to 404 again


Modify the main configuration class (Application)


1. We need to inherit SpringBootServletInitializer class

@SpringBootApplication  
public class MainSpringApplication extends SpringBootServletInitializer {

2. Override a method

 protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
     return application.sources(SecurityApplication.class);
 }

3. End effect

@SpringBootApplication public class MainSpringApplication extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(MainSpringApplication.class); } public static void main(String\[\] args) { SpringApplication.run(MainSpringApplication.class, args); }}


Third, re-process


1. Run locally with the same function as before the main Application configuration class was not changed


2. Clean install


3. Stop tomcat


4. Upload the WAR package to WebApps


5. Start tomcat


6. The request url


A success


IV. Other minor problems encountered in the process


Maven packages an errorhttp://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

An easy mistake to make:

But it’s also easy to fix:

1. Your target file is occupied and cannot be packaged. So release the back to occupy the Target folder, and then pack it. (Mine is the problem)

2. After the project is updated, if there is a problem with the dependent package, clean, flush, and then package it.

3. Your Maven project has parent and child dependencies. POM is configured in a different way, so it cannot be packaged. At this point, use the Parent project to clean and install, and then all the packages are printed.

4…