<> One , background

For our rapid development provides a good shelf , So that we only need a small amount of configuration to start our development work , But when we need to package the upload deployment , It's a very sad question , Because it was typed Jar
Less than ten trillion packets , More than 100 trillion , When we need to upload to the public network server , It's very slow , This leads to today's theme ,SpringBoot project Jar How to thin package deployment

<>1, thinking

* analysis jar, We can see that ,jar The package is divided into the following three modules

Divided into BOOT-INF,META-INF,org Three parts , open BOOT-INF

You can see that there are classes,lib Two folders , Our compiled code is placed in the classes Inside , And what we depend on jar The bags are all in the lib Under folder
* classes Part of it is very small ( Mine is 3M about ),lib Part of it is very large ( Mine is 70M about ), So the upload is slow
* Then we can combine the part of our own code with the dependent code maven jar The package part is disassembled and uploaded , Each time we just need to upload the code we wrote
<> Two , Lean deployment

<>1, Normal packing

first , Our project pom.xml The package in the file is as follows :
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <
artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>
* This is SpringBoot The default packing method in , Let's package it in this way , Get one jar package ,
* We will jar Package decompression , If you can't decompress directly , Change the suffix to zip Then decompress
* We just need to get it BOOT-INF Medium lib Catalog is OK
<>2, Change packaging

We are right SpringBoot Do some configuration for the default packaging method in
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <
artifactId>spring-boot-maven-plugin</artifactId> <configuration> <mainClass>com.
zyxx.DeclareApplication</mainClass> <layout>ZIP</layout> <includes> <include> <
groupId>nothing</groupId> <artifactId>nothing</artifactId> </include> </includes
> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </
goals> </execution> </executions> </plugin> </plugins> </build>
* mainClass, We specified the startup class for the project
* layout, We have specified the packing method as ZIP, be careful : It must be in capitals
* includes, Have their own dependence jar, You can import it here
* repackage, Eliminate other dependencies , Just keep the simplest structure
<>3, Pack again

We click again maven package, Get one jar package , You can see the jar The bag is only a few trillion

<> Three , Upload start

We will lib catalog , And the final package of slimming programs jar package , Upload to server , The contents are as follows

Using commands
nohup java -Dloader.path=./lib -jar ./sbm-0.0.1-SNAPSHOT.jar &
* -Dloader.path, Tell it what it depends on maven jar Package location
* sbm-0.0.1-SNAPSHOT.jar, project jar The name of the bag
* nohup,&, bring jar The package runs in the service background
<> Four , summary

Use lean deployment , It is convenient to update every iteration , You don't have to upload a big one every time jar package , This saves deployment time

If you find a deficiency in your reading , Welcome to leave a message !!!

©2020 ioDraw All rights reserved
python gui Interface examples -Python GUI Programming complete example IO flow —— Classification of flow ,InputStream,OutputStream,Reader,Writer etc. Thread.setDaemon Set up the Daemons STM32 RS485 modbus Communication source program , The test is effective stay MATLAB 2018 Time series prediction with deep learning vue3 Write component library and publish to npm The process of Questions and answers for the interviewer : How did you get a project in the project team ??? In the applet form Multiple cycles input How to get each input Value of 2021 Front end high frequency interview questions ( You have to watch it !!!)js Array method