2

I know this question popped up here and there but the posts about this are quite old.
I have a Spring Boot application. I have the need to allow developers develop plugins, implementing an interface and allow my application to load them dynamically on startup.
I don't need discovery on run time, loading at startup is good enough.
I don't want my clients to develop micro services. I want in process modules that will be loaded into the application.
Writing a XML file with plugins to load list is an option although I prefer simple as possible configuration and if this need can be avoided it's better. I have seen some options:

  • OSGi (Very heavy duty for my needs)
  • JPF (Last update on 2007)
  • JSPF (I can't even find a github page for this one).

I really want something quick and easy without a steep learning curve. As mentioned it should play nicely with Spring Boot. What are my options?

Yaron
  • 2,209
  • 3
  • 18
  • 33

1 Answers1

1

You can use the PropertiesLauncher to add additional paths to your app:

The Main Class must be:

Main-Class: org.springframework.boot.loader.PropertiesLauncher

And then you can start the app:

java -Dloader.path=lib,external-jar.jar -jar my-app.jar

Please read more about that here : https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#executable-jar-launching

and here https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#executable-jar-property-launcher-features

Réda Housni Alaoui
  • 1,244
  • 2
  • 15
  • 22
Simon Martinelli
  • 34,053
  • 5
  • 48
  • 82
  • Maybe I understood you wrong... I'm not looking for launching executable... I need to load the contained classes in these jars, instantiate them and calling the interface methods inside them... – Yaron Mar 03 '20 at 09:28
  • 1
    Which is exactly what this answer gives you. You can drop your plugins in the `lib` directory and they will be detected at startup. And yes you are looking for a different way to execute the Spring Boot application (the executable). – M. Deinum Mar 03 '20 at 09:44