JAR分离打包 · JeecgBoot 开发文档 · 看云

SpringBoot瘦身(lib和程序分开打包)

1. 首先用mvn clean package正常打出jar包

这个jar包可能有几百兆大小,lib占了绝大多数
将jar包解压,将 BOOT-INF 下的 lib 包拿出单独存放

2. 修改pom重新打包

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<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>

img

再次用 mvn clean package 打出来的包就不包含lib了

3. 运行jar包

#C:\111111\lib为lib包路径,执行下面命令启动项目

1
java -Dloader.path=C:\111111\lib -jar jeecg-boot-module-system-2.3.0.jar

4.目录结构

img