In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces you how to slim down the deployment of SpringBoot, the content is very detailed, interested friends can refer to, hope to help you.
I. Preface
Although the deployment of SpringBoot is simple, if the server is deployed on the company's private network, the speed is OK, but if it is deployed on a public network (Ali Cloud and other cloud servers), it is a headache: the compiled Jar package is very large, and if many open source components (SpringCloud, etc.) are introduced into the project, it will be even bigger.
At this time, if you want to make some fine-tuning to the online project, it will be very painful.
2. Jar bag before slimming
When Tomcat deploys the Web project, it can be updated incrementally, and so can SpringBoot.
Among the Jar packages compiled by SpringBoot, the ones with large disk footprint are some externally dependent libraries (jar packages), such as:
Enter the root directory of the project, execute the mvn clean install command, and open the resulting Jar package with compressed software. The directory structure is as follows:
The entire Jar package is 18.18 MB, but BOOT-INF/lib takes up nearly 18 MB:
III. Solutions
Step 1: compile the JAR package normally and extract the lib folder
The POM file is as follows:
Enter the project root directory and execute the command: mvn clean install
Extract the compiled Jar package and copy the lib folder in the BOOT-INF directory to the target path
Step 2: modify the pom.xml configuration to compile the Jar package without the lib folder
Once the configuration is complete, execute the compilation again: mvn clean install
The resulting Jar package is significantly smaller, as shown below, and the external jar package will no longer be introduced:
Step 3: run the compiled Jar package
Put the lib folder extracted from step 1 and the jar package compiled in step 2 in the same directory, and run the following command:
Or enter the command in maven to export the jar package you need.
Remarks
Change / path/to/ to the actual path.
-Dloader.path=lib folder path
The final directory file structure is:
Description
1. Usually, after the architecture of an engineering project is determined, the jar package introduced will basically remain unchanged, and most of the changes will be business logic.
2. Later, if you need to change the business logic, you only need to compile the project lightly, which greatly improves the efficiency of project deployment.
On how to carry out the slimming deployment of SpringBoot to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.