I would like to add a configuration directory to the classpath for a spring boot application at start up, so it can load xml files from the configuration directory.
ie /var/application/config contains test.xml, dev.xml
The xml will contain mapping information that is required by the application; this is different from application.properties.
I would like to load them at startup.
I am using ClassPathResource to load the files.
Please advise.
You can define your own classpath
by the command-line. Lets suppose your jar is myapp.jar
and you wand add one extra directory /var/application/config/
, so you can execute with the following command line:
java -cp myapp.jar:/var/application/config/ -Dloader.main=myapp.Application org.springframework.boot.loader.PropertiesLauncher
ps: if you are using Windows use ;
instead of :
to separate your classpath
items.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With