posted 2 years ago
I have a spring boot application . I want to load external jars from an external folder at runtime in the spring boot application after the application is started without restarting the context. The external jar contains @Service , @Component annotated classes.
What I have tried till now:
I loaded all the classes from the external jar at runtime . I have used a watcher which triggers the loader whenever there is a jar added to the folder being watched.
Below are the steps:
1) Autowire annotationconfigapplicationcontext bean .
2) Load the classes from the external folder using loader
3) register those classes in annotationconfigapplicationcontext
4) restart the annotationconfigapplicationcontext
Also i tried autowiring the classes programatically but the drawback with that is that there might be a @Service class dependent on another @Component class hence I need to maintain the bean creation order which is hard to handle programatically.
Is there a way i can load the classes from the external jar without restarting the application context.