Issue
I am building a software system to interact with an enterprise software system, using Spring Boot. My system depends on some jars and *.ini files from that enterprise system, so I cannot pack all dependencies in Maven. I would like to be able to run Spring Boot as Executable Jar with embedded Tomcat. I would also like to be able to set the classpath via the command line. So something like:
java -classpath /home/sleeper/thirdparty/lib -jar MyApp.jar
However, -classpath and -jar cannot co-exist. I have tried "-Dloader.path". It was able to load all the jar files under the folder, but not other things, like *.ini files in the folder.
So is there a way we can make -classpath to work with an Spring executable jar with embedded Tomcat?
Thank you in advance for all the help.
Solution
If you just want add external libraries you can use the loader.path
property.
java -Dloader.path="your-lib/" -jar your-app.jar
UPDATE
If you also need to read additional files from the classpath you have to create/change the manifest file of your application.
Lets assume that your are initializing your Spring Boot context from the class de.app.Application
. Your MANIFEST.MF
should looks as follows:
Manifest-Version: 1.0
Main-Class: de.app.Application
Class-Path: your-lib/
And the you can simply start your app with java -Dloader.path="your-lib/" -jar MyApp.jar
.
For more information about the MANIFEST.MF please see Working with Manifest Files: The Basics.
Answered By - Paul Wasilewski
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.