title: Dynamically add jars to SpringBoot at runtime
body: <p>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 <code>spring-boot-maven-plugin</code> because I won't have the spring boot application's pom when I want to launch it.</p>
  
  <p>I have tried the following so far, where <code>my-jar.jar</code> is the spring boot application and <code>external-jar.jar</code> is the external jar I want to include on the command line:</p>
  
  <pre><code>java -cp my-jar.jar -Dloader.path=external-jar.jar -Dloader.main=com.my.Application org.springframework.boot.loader.JarLauncher
  </code></pre>
  
  <p>This launches but does not component scan <code>external-jar.jar</code></p>
  
  <pre><code>java -cp external-jar.jar:my-jar.jar -Dloader.main=com.my.Application org.springframework.boot.loader.JarLauncher
  </code></pre>
  
  <p>This fails to launch, saying <code>@Autowired</code> conditions in <code>external-jar.jar</code> were not satisfied, even though classes in <code>my-jar.jar</code> do satisfy them. I have tried reversing the order of the jars on the classpath, this doesn't fix the issue.</p>
  
  <pre><code>java -Dloader.path="external-jar.jar" -jar my-jar.jar
  </code></pre>
  
  <p>This launches but does not component scan <code>external-jar.jar</code></p>
  
  <p>My component scanning path at the top of my SpringApplication class has a package paths for both <code>my-jar.jar</code> and <code>external-jar.jar</code> and I have verified that when referencing <code>external-jar.jar</code> directly within my pom it is component scanned.</p>