ruseel
ruseel

Reputation: 1734

spring-boot - how to specify path of application.properties in envrionment or system properties?

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?

Upvotes: 6

Views: 21873

Answers (4)

yaghob abbasi
yaghob abbasi

Reputation: 96

use bellow code above main class:

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

Upvotes: 0

Satish Kr
Satish Kr

Reputation: 628

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 

Upvotes: 7

Ravi Prashant
Ravi Prashant

Reputation: 1

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

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

Upvotes: 0

ruseel
ruseel

Reputation: 1734

environment variable SPRING_CONFIG_LOCATION can be also used.

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

Upvotes: 3

Related Questions