I'm using SpringBoot 1.4.2. I want to be able to launch my SpringBoot application from the command line, specifying additional, external jars that should also be component scanned at the time I launch the application. I can't use the spring-boot-maven-plugin
because I won't have the spring boot application's pom when I want to launch it.
I have tried the following so far, where my-jar.jar
is the spring boot application and external-jar.jar
is the external jar I want to include on the command line:
java -cp my-jar.jar -Dloader.path=external-jar.jar -Dloader.main=com.my.Application org.springframework.boot.loader.JarLauncher
This launches but does not component scan external-jar.jar
java -cp external-jar.jar:my-jar.jar -Dloader.main=com.my.Application org.springframework.boot.loader.JarLauncher
This fails to launch, saying @Autowired
conditions in external-jar.jar
were not satisfied, even though classes in my-jar.jar
do satisfy them. I have tried reversing the order of the jars on the classpath, this doesn't fix the issue.
java -Dloader.path="external-jar.jar" -jar my-jar.jar
This launches but does not component scan external-jar.jar
My component scanning path at the top of my SpringApplication class has a package paths for both my-jar.jar
and external-jar.jar
and I have verified that when referencing external-jar.jar
directly within my pom it is component scanned.