Reputation: 217
I was trying to understand if I have some properties in application.yml and a few in application.properties will my application read from both these files?
Upvotes: 2
Views: 4579
Reputation: 111
According to Spring documentation - Change the Location of External Properties of an Application:
No matter what you set in the environment, Spring Boot always loads application.properties as described above. By default, if YAML is used, then files with the ‘.yml’ extension are also added to the list.
In which order properties are considered is explained in the chapter Spring documentation - Externalized Configuration.
If in doubt what files have been loaded I recommend to set the log level to DEBUG
which shows the loaded configuration files in the log.
Upvotes: 2
Reputation: 4647
There is a good article here, that describes how both of these can be read using the @ConfigurationProperties
annotation.
@ConfigurationProperties
supports both .properties
and .yml
files.
@ConfigurationProperties
support JSR-303
bean validation – javax.validation
Hope this helps!
Upvotes: 1