6

If I want to run spring boot application, and want to use difference application.properties in difference path (other than using profile)

How can I specify path for application.properties?

2
  • 2
    --spring.config.location=file:/{path}/application.properties Commented Apr 23, 2019 at 5:18
  • @kzharas210 that should be -Dspring.config.location= FYI Commented May 9, 2022 at 4:53

4 Answers 4

7

If you want to use difference application.properties in difference path, use this command to start the jar file

nohup java -jar project.jar --spring.config.location=file://{file-path}/application.properties 
Sign up to request clarification or add additional context in comments.

Comments

3

environment variable SPRING_CONFIG_LOCATION can be also used.

https://docs.spring.io/spring-boot/docs/current/reference/html/howto-properties-and-configuration.html

1 Comment

0

@PropertySource annotation is used to provide properties file into the environment and it is used with @Configuration classes.

@PropertySource({ "classpath:config.properties" })

Comments

0

use bellow code above main class:

@PropertySource(value = {"file:///${HOMEDIR}/application.properties"}) 

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.