Sat
Sat

Reputation: 33

Loading a external jars dynamically in a spring boot application @runtime

We have a spring boot application which is referring to a 3rd party jar . The 3rd party jar is having all getters and setters . But this external JAR keeps changing periodically . This external jar is places in shared location . Is there a way by which spring boot application will be made aware of new verion of external jar whenever its gets changed and spring boot should dynamically load the new external jar programmatically.

Upvotes: 3

Views: 9231

Answers (2)

user489041
user489041

Reputation: 28312

I don't believe you can load a jar more than once. We had a similar use case when we were using JNI and had to load DLLs. The problem you will run into is you need the garbage collector to clean up references to the old library.

Long story short, avoid doing this at all costs. There are better paradigms

Upvotes: 0

kumar
kumar

Reputation: 497

@Sat....try this one credit goes to....

Dynamically add jars to SpringBoot at runtime

java -cp my-jar.jar -Dloader.path=external-jar.jar -Dloader.main=com.my.Application org.springframework.boot.loader.PropertiesLauncher

Upvotes: 1

Related Questions