mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-15 01:07:30 +08:00
Polish Externalized Configuration section
Closes gh-3823
This commit is contained in:
parent
6869b0d987
commit
6393569d42
@ -224,7 +224,9 @@ Spring Boot allows you to externalize your configuration so you can work with th
|
||||
application code in different environments. You can use properties files, YAML files,
|
||||
environment variables and command-line arguments to externalize configuration. Property
|
||||
values can be injected directly into your beans using the `@Value` annotation, accessed
|
||||
via Spring's `Environment` abstraction or bound to structured objects.
|
||||
via Spring's `Environment` abstraction or
|
||||
<<boot-features-external-config-typesafe-configuration-properties,bound to structured objects>>
|
||||
via `@ConfigurationProperties`.
|
||||
|
||||
Spring Boot uses a very particular `PropertySource` order that is designed to allow
|
||||
sensible overriding of values, properties are considered in the the following order:
|
||||
@ -244,7 +246,8 @@ sensible overriding of values, properties are considered in the the following or
|
||||
variants).
|
||||
. Application properties packaged inside your jar (`application.properties` and YAML
|
||||
variants).
|
||||
. `@PropertySource` annotations on your `@Configuration` classes.
|
||||
. {spring-javadoc}/context/annotation/PropertySource.{dc-ext}[`@PropertySource`] annotations
|
||||
on your `@Configuration` classes.
|
||||
. Default properties (specified using `SpringApplication.setDefaultProperties`).
|
||||
|
||||
To provide a concrete example, suppose you develop a `@Component` that uses a
|
||||
@ -315,7 +318,8 @@ following locations and add them to the Spring `Environment`:
|
||||
. A classpath `/config` package
|
||||
. The classpath root
|
||||
|
||||
The list is ordered by precedence (locations higher in the list override lower items).
|
||||
The list is ordered by precedence (properties defined in locations higher in the list
|
||||
override those defined in lower locations).
|
||||
|
||||
NOTE: You can also <<boot-features-external-config-yaml, use YAML ('.yml') files>> as
|
||||
an alternative to '.properties'.
|
||||
|
Loading…
Reference in New Issue
Block a user