- springboot2.2.6.RELEASE chapter1
- springboot2.2.6.RELEASE chapter1
- springboot2.2.6.RELEASE chapter1
- springboot2.2.6.RELEASE chapter1
- springboot2.2.6.RELEASE chapter1
- springboot2.2.6.RELEASE chapter1
- springboot2.2.6.RELEASE chapter1
- springboot2.2.6.RELEASE chapter1
- springboot2.2.6.RELEASE chapter1
- springboot2.2.6.RELEASE chapter1
spring.config.name and spring.config.location are used very early to determine
which files have to be loaded. They must be defined as an environment property
(typically an OS environment variable, a system property, or a command-line
argument).
If spring.config.location contains directories (as opposed to files), they should end in / (and, at
runtime, be appended with the names generated from spring.config.name before being loaded,
including profile-specific file names). Files specified in spring.config.location are used as-is, with
no support for profile-specific variants, and are overridden by any profile-specific properties.
Config locations are searched in reverse order. By default, the configured locations are
classpath:/,classpath:/config/,file:./,file:./config/. The resulting search order is the following:
- file:./config/
- file:./
- classpath:/config/
- classpath:/
When custom config locations are configured by using spring.config.location, they replace the
default locations. For example, if spring.config.location is configured with the value
classpath:/custom-config/,file:./custom-config/, the search order becomes the following:
- file:./custom-config/
- classpath:custom-config/
Alternatively, when custom config locations are configured by using spring.config.additionallocation,
they are used in addition to the default locations. Additional locations are searched before
the default locations. For example, if additional locations of classpath:/customconfig/,
file:./custom-config/ are configured, the search order becomes the following:
- file:./custom-config/
- classpath:custom-config/
- file:./config/
- file:./
- classpath:/config/
- classpath:/
This search ordering lets you specify default values in one configuration file and then selectively
override those values in another. You can provide default values for your application in
application.properties (or whatever other basename you choose with spring.config.name) in one of
the default locations. These default values can then be overridden at runtime with a different file
located in one of the custom locations.
网友评论