How do we load additional jar at runtime along with boot jar.
Primary jar: Main
.jar
Additional jar: Support
.jar
Main
project is a gradle boot project.
Support
project is NOT a gradle project but is given compile time dependencies to the required jars.
Contents of Support project:
@RestController
@RequestMapping("/test")
public class CustomService implements WebMvcConfigurer {
@RequestMapping(value = "/hello", method = RequestMethod.GET)
public @ResponseBody String get() {
return "Done!!";
}
}
What i tried:
java -cp Support.jar:Main.jar -Dloader.path=Support.jar -Xbootclasspath/p:alpn-boot-8.1.11.v20170118.jar -Dloader.main=com.abc.app.MyApplication org.springframework.boot.loader.PropertiesLauncher
The boot starts up fine but the endpoint is not registered.
NOTE: I had mentioned annotation scanning.
@SpringBootApplication
@ComponentScan("com.abc")
public class MyApplication {
....
}
Also the Main.jar will be run from various places by various users. Each user might provide his own version of Support.jar. So, hardcoding the dependency into the gradle file of Main project is not feasible.