Background
With the popularity of spring boot, more and more to choose to use Spring boot to send web apps, unlike traditional Web applications that require a war package to publish an app, a spring boot app can package an entire project into an executable jar, while also guiding The jar is becoming bigger and larger. For the current high-speed iteration of the project, uploading such a large jar to the sender is a very painful thing. This chapter describes how to extract small jars that vary in the project to the outside.
Specific steps:
1: Usually we use Spring-boot-maven-plugin to package, by reading the document discovery can be configured so that the plug-in is packaged to ignore the specific dependencies, the document in Spring-boot-maven-plugin
2: First back up the original dependency: You can use MVN dependency:copy-dependencies first to export dependent.
3: Copy the jar with small changes to the external file Lib folder (corresponding to the configuration in the Pom file)
4: Modify the Pom file as follows:
<build><plugins><plugin ><groupid>org.springframework.boot</groupid><artifactid>spring-boot-maven-plugin</ Artifactid><configuration> <layout>ZIP</layout> <!--Remove the constant dependency in the production environment-<excludeGroupIds> Org.springframework.boot, Org.springframework, Org.springframework.data, org.apache.tomcat.embed </excludeGroupIds> </configuration></plugin>& lt;/plugins></build>
Note: layout must be in ZIP, Excludegroupids, and will need to be in the external jar, according to the situation of their own project configuration
5: Project startup put the jar of the project and the Lib you just created in the sibling directory (not required).
6: Startup Project: Java-dloader.path= "lib/"-jar Xx.jar
Well, that's the end of the basics, if you have any questions, please.
Spring Boot Package Slimming method