Spring Boot Plugin System for Modular Applications
I am looking for dynamic jar loading in spring boot after compilation, for example, I will put the jars in some folder and when spring boot starts, all jars from that folder will be added to spring boot application. I dont know how to do this on spring boot and if you know can help me with this, with some example.
I need these jars to @Service, @Controller as it will be a module (plugin) with added capabilities to my spring boot app.
This can be done on spring boot and if possible please provide me with some sample code.
Thanks in advance.
UPDATE: I found something https://www.youtube.com/watch?v=F-sw2pFdcDw https://code.google.com/p/jspf/
UPDATE 2: I cannot get the @Controller bean from the plugin banner registered in spring Boot
source to share
One option is to just use advanced @ComponentScan
. If you add a new jar to classpath
, annotated classes from that jar will be discovered through @ComponentScan
, @Controller
displayed, etc.
Here, the XML equivalent will put the config files xml
somewhere in your classpath ( META-INF
- obvious choice) and import them all using a wildcard. The idea is the same. If the plugin jar file is on the classpath, you will get the imported file xml
and the beans (controllers ...) will be loaded.
There are drawbacks to this approach such as modules that are not isolated, but a definite option for simpler applications.
source to share