spring boot fat jar 引入新的jar 文件到classpath

时间:2021-08-17 10:24:00   收藏:0   阅读:19

bootstrap classpath

-Xbootclasspath: 完全取代基本核心的Java class 搜索路径.不常用,否则要重新写所有Java 核心class
-Xbootclasspath/a: 后缀。将classpath添加在核心class搜索路径后面。常用!!
-Xbootclasspath/p: 前缀。将classpath添加在核心class搜索路径前面.不常用,避免引起不必要的冲突.
 java -Xbootclasspath/a:./lib: -jar  ui-0.0.1-SNAPSHOT.jar

使用property-launcher

java -cp example.jar -Dloader.path=./lib org.springframework.boot.loader.PropertiesLauncher

说明

使用property-launcher 是spring boot标准的玩法,是推荐使用的(尤其是包含了bean 依赖相关的)参考链接包含了一个demo
就是集成了上边2的方法,解决外部spring boot 加载bean 的

参考解决方法

https://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html#executable-jar.property-launcher
https://stackoverflow.com/questions/40499548/how-to-configure-additional-classpath-in-springboot
https://github.com/rongfengliang/spring-boot-external-jar-load

原文:https://www.cnblogs.com/rongfengliang/p/15150072.html

评论(0)
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!