Dejan Mladenovski
Dejan Mladenovski

Reputation: 333

Spring Boot external configuration without ignoring the packaged configuration

I am developing a Spring Boot JAR application and what I want is for some configuration properties to be found in an external path. I want something like this:

the jar to be located at /home/myapps/my-spring-boot-app.jar

the configuration to be located at /apps/configuration/app/config.properties

I have set the spring-boot-maven-plugin with layout:ZIP and I have tried with different configurations like spring.config.location="/apps/configuration/app/" and loader.path="/apps/configuration/app/" and it didn't work.

In some cases, it ignored my external configuration, and in some cases, it ignored my packaged configuration. I don't want to use the Spring Boot defined hierarchy, to have the configuration in ./config/

Thanks for the help

Upvotes: 2

Views: 138

Answers (1)

Michał
Michał

Reputation: 641

Acording to documentation: https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html spring.config.location can accept more than one file, so you can try something like this:

spring.config.location=classpath:/application.properties,/apps/configuration/app/config.properties or just directories: spring.config.location=classpath:/,/apps/configuration/app/

Upvotes: 6

Related Questions