0

I’m executing a jar and passing a properties file in args

java - jar file.jar props.properties 

To read the properties file I’m using java.util.Properties.load. I want to know if there is a better way to do this with spring boot because properties file can exist in different locations or with different names but always the same properties.

I tried with PropertySource but I couldn’t find a way to set properties file dynamically

1
  • "...because properties file can exist on different locations or with different names but always same properties." - Normally, your deployment pipeline should take care of this. Your deployment pipeline should provision the property file to some path in the file system and then start the application, passing along the location of the property file. Commented Aug 21, 2019 at 23:17

1 Answer 1

4

You can use:

java -jar app.jar --spring.config.location=file:///Users/home/config/jdbc.properties 

More information here: https://www.baeldung.com/spring-properties-file-outside-jar

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.