The fat jar of Spring Boot contains the jar of the dependent library, but I will describe how to load the external jar at runtime.
It is not often used, but it is used when the library provides different jars for each environment.
By default, JarLauncher
is used to launch the Executable Jar, and it goes underBOOT-INF / lib /
in the jar.
Use PropertiesLauncher
instead to change the classpath etc. at runtime.
build.gradle
settingsbootJar {
manifest {
attributes 'Main-Class': 'org.springframework.boot.loader.PropertiesLauncher'
}
}
loader.path
Specify the classpath you want to add with the loader.path
property. The environment variable LOADER_PATH
may be used.
Thankfully, you can also specify a directory and it will recursively scan the jar or zip file.
export LOADER_PATH=/develop
java -jar app.jar
Recommended Posts