美文网首页
springboot2.2.6.RELEASE chapter1

springboot2.2.6.RELEASE chapter1

作者: 淼哥1986 | 来源:发表于2020-04-04 09:28 被阅读0次

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:

  1. file:./config/
  2. file:./
  3. classpath:/config/
  4. 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:

  1. file:./custom-config/
  2. 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:

  1. file:./custom-config/
  2. classpath:custom-config/
  3. file:./config/
  4. file:./
  5. classpath:/config/
  6. 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.

相关文章

网友评论

      本文标题:springboot2.2.6.RELEASE chapter1

      本文链接:https://www.haomeiwen.com/subject/iordphtx.html