随笔 - 253,  文章 - 0,  评论 - 29,  阅读 - 25万

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

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

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

2. 修改pom重新打包

复制代码
复制代码
            <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>
复制代码
复制代码

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

3. 运行jar包

#D:\jar\xc-springboot-0.0.2-SNAPSHOT\lib为lib包路径,执行下面命令启动项目。

java -Dloader.path=D:\jar\xc-springboot-0.0.2-SNAPSHOT\lib -jar xc-springboot-0.0.2-SNAPSHOT.jar

d:
cd D:\jar
@echo off 
java -Dloader.path=D:\jar\xc-springboot-0.0.2-SNAPSHOT\lib -jar xc-springboot-0.0.2-SNAPSHOT.jar
exit

posted on   田坤坤  阅读(92)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
历史上的今天:
2019-05-07 拖拽复制

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示