Mehdi Alisoltani
Mehdi Alisoltani

Reputation: 399

Externalize Config File Java Spring

I have a legacy Spring project which has multiple configuration files located in class path.

With the pre-suggested command for compiling and packaging this project I use the following command:

mvn package appassembler:assemble -P dev

and it make jar file as well as a script for running the project ,and every thing working fine.

But, the challenging is this approach put all artifacts including config files into the jar file and in deployment, I should unpackaging the jar file, changing configurations and repackage it again.(e.g. changing ports, IPs and some credentials ,...)

I want to know, is there any way telling appassembler to put config files outside the jar or any other way to solve the problem with the minor code change ?

Although, it is possible using -Dspring.config.location but, every time I compile the project I have to change the script which is created by the appassembler.

Upvotes: 0

Views: 158

Answers (1)

Eskandar Abedini
Eskandar Abedini

Reputation: 2144

Spring Properties File Outside jar

spring.config.import=file:./additional.properties,optional:file:/Users/home/config/jdbc.properties

Externalized Configuration

Upvotes: 1

Related Questions