且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在运行时将jar文件添加到spring-boot类路径

更新时间:2021-07-01 00:50:50

您需要使用PropertiesLauncher而不是JarLauncher:

You need to use PropertiesLauncher instead of JarLauncher:

java -cp "yourBoot.jar" -Dloader.path=plugins/ -Dloader.main=your.mainClass org.springframework.boot.loader.PropertiesLauncher

这将使Java将plugins目录中的jar加载到上下文中,并将这些jar中标记为@Configuration的所有类都加载到上下文中.

This will make java load the jars in the plugins directory and spring load all the classes in those jars marked as @Configuration into the context.