spring-boot-maven-plugin 打包分离依赖lib

本文介绍了如何使用spring-boot-maven-plugin配合maven-dependency-plugin将依赖lib分离出来,避免将所有依赖打包进jar。通过设置spring-boot-maven-plugin的includes属性并结合maven-dependency-plugin将依赖拷贝到lib目录,可以实现仅传输核心jar包的需求。在启动时需要注意使用java.ext.dirs指定lib路径,以避免某些内置库调用失败的问题。
摘要由CSDN通过智能技术生成

1. 问题: spring-boot项目,默认生成的pom使用spring-boot-maven-plugin打包,会把所有依赖项都打进jar文件中,在调试阶段需要频繁传输jar包时很痛苦。

2. 查找:上网搜索”maven 打包 依赖分离”等关键字,多数文章使用了maven-jar-plugin或其他插件,把spring-boot-maven-plugin替换掉了,例如:https://www.iteye.com/blog/icw-zy-2380977

不说会不会有什么影响,单纯就觉得不完美 -- 自动生成的spring-boot-maven-plugin就真的不能用了么?

3.梳理:

先看spring-boot-maven-plugin官文 [https://docs.spring.io/spring-boot/docs/current/maven-plugin/reference/htmlsingle ],其中有一节

5.3.5. Dependency Exclusion

By default, both the repackage and the run goals will include any provided dependencies that are defined in the project. A Spring Boot project should consider provided dependencies as "container" dependencies that are required to run the application.

Some of these dependencies may not be required at all and should be excluded from the executable jar. For consistency, they should not be present either when running the application.

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值