0

I am planning a spring boot application that can be extended with plugins. However, I haven't found out yet whether spring boot meets my requirements in this regard.

I imagine the following folder structure:

  • application
    • core <-- core jars
      • main_application.jar
      • ...
    • plugins
      • PluginTypA <-- pluginTypA jars
      • PluginTypB <-- pluginTypB jars
      • PluginTypC <-- pluginTypC jars
      • ...
    • ...

Does Spring Boot provide a way for the core application to automatically detect and load these plugins? How can I get the annotated classes of my plugins to be included in the ApplicationContext of the core application?

Update: When I develop the core application, I don't know which plugins are developed in future and which package name they will have. So the core application has to get known about the plugins on runtime or startup and add the Components to the ApplicationContext.

Example: My coreApplication provides a plugin type for importing data. Actual there is just the need to import .csv files. In one year i get the requirement to import .xlsx files. I don't want to update the whole application, i just want to write a plugin, package it and then copy it to the folder of the plugin type and restart my core application.

5
  • The @ComponentScan annotation might be what you are looking for : stackoverflow.com/questions/28679581/…
    – BMerliot
    Apr 16, 2019 at 0:02
  • I'am not sure, if this is what I'am searching for. When I develop the core application, I don't know which plugins are developed in future and which package name they will have. So the core application has to get known about the plugins on runtime or startup and add the Components to the ApplicationContext.
    – schneidolf
    Apr 16, 2019 at 4:56
  • You mean something like this: blog.frankel.ch/java-service-loader-vs-spring-factories ?
    – Marged
    Apr 16, 2019 at 5:35
  • Spring boot has a feature called "AutoConfigurarion" which works very similar to ServiceLoader. Should be exactly what you are looking for. Jars must be on the classpath, though
    – marstato
    Apr 16, 2019 at 10:34
  • Thank you for your answers. I think a mixture of all answers is what I was looking for. After trying it out I will give response.
    – schneidolf
    Apr 17, 2019 at 19:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.