With the new version, however, the framework follows the same ordering rules that we indicated earlier for. Previously, the order in which they were added was based on the profile activation order. It's also worth mentioning that YAML files do not support the annotation, so if we need to use this annotation, it would constrain us to using a properties file.Īnother remarkable point is that in version 2.4.0 Spring Boot changed the way in which properties are loaded from multi-document YAML files. Url: jdbc:postgresql:/localhost:5432/instance Is synonymous with the following YAML file: database: YAML is particularly good for hierarchical property storage the following property file: database.url=jdbc:postgresql:/localhost:5432/instance Note that for properties files, the three-dashes notation is preceded by a comment character ( #). Since version 2.4.0, Spring Boot supports using multi-document properties files, similarly as YAML does by design: baeldung.customProperty=defaultValue This comes in handy when we have multiple sources of configuration properties. This way, Spring Boot will look for configuration files matching the config/*/ directory pattern outside of our jar file. We can also configure a different file at runtime if we need to, using an environment property: java -jar app.jar =classpath:/another-location.propertiesĪs of Spring Boot 2.3, we can also specify wildcard locations for configuration files.įor example, we can set the property to config/*/: java -jar app.jar =config/*/ So, by using this default file, we don’t have to explicitly register a PropertySource or even provide a path to a property file.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |