Spring Boot Package Slimming method

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.