How can I access values provided in application.properties, like logging.level.org.springframework.web: DEBUG logging.level.org.hibernate: ERROR logging.file=${HOME}/application.log userBucket.path=${HOME}/bucket For instance, I want to access userBucket.path in my main program in a Spring Boot application.
Home/properties file
Option 1: You can use the @Value annotation and access the property in whichever Spring bean you're using @Value("${userBucket.path}") private String userBucketPath; The Externalized Configuration section of the Spring Boot docs, explains all the details that you might need. Option 2: AnotherRead more
Option 1:
You can use the
@Value
annotation and access the property in whichever Spring bean you’re usingThe Externalized Configuration section of the Spring Boot docs, explains all the details that you might need.
Option 2:
Another way is injecting
See lessorg.springframework.core.env.Environment
to your bean.