Since springboot commonly deploys war packages, when it is changed to cloud development mode with multiple ports, the deployment is not used to it
After all, the war package must be placed in the root directory of tomcat whether it is accessed by the project name or not
This directory is restricted to only one project, and the login port is limited to the tomcat interface
Therefore, jar package deployment has become an inevitable method
1. Add pom settings
Static files need to be accessed, so the files under the static file webapp need to be re-specified. The specific configuration is as follows
src/main/webapp META-INF/resources **/*.* false
2. The packaging method is from war Change the package to a jar package
1. Comment the war package mode
jar
2. Comment the war-plugin
org.springframework.boot spring-boot-maven-plugin org.supwisdom.Application
3. Comment out spring-boot-starter-tomcat related dependencies
4. Comment out SpringApplicationBuilder configure## in Application.java
#
// @Override // protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { // return application.sources(Application.class); // } public static void main(String[] args) throws Exception { System.setProperty("spring.devtools.restart.enabled", "false"); SpringApplication.run(Application.class, args); }
Startup method:
mvn clean package java -jar target/***.jarBut the actual Certain problems occurred during use. For example, during development, modifications to the static file code did not always respond, and clearing the browser cache was of no use. Therefore, the cache exists in the jar packaged by springboot. , so it is better to comment out the above content during development
The above is the detailed content of How to deploy jar package in springboot. For more information, please follow other related articles on the PHP Chinese website!