当前位置:   article > 正文

spring boot 配置 spring.config.location

spring.config.location

1 . 2.x版本

   spring.config.location 设置后,只读取这个文件配置内容,不再读取其他地址的配置文件

     根据官方文档表述,默认会读取

         
  1. 1. file:./config/
  2. 2. file:./config/*/
  3. 3. file:./
  4. 4. classpath:/config/
  5. 5. classpath:/

 在使用 spring.config.location 指定外部配置文件时,需要此份配置文件需全量满足当前工程运行时所需,因为它不会去与 resources 目录下的配置文件去做 merge 操作。

2.  spring.config.additional-location

  配置后加载顺序,属性会merge. 同名属性以优先级高的为准

  1. 1. file:./custom-config/
  2. 2. classpath:custom-config/
  3. 3. file:./config/
  4. 4. file:./config/*/
  5. 5. file:./
  6. 6. classpath:/config/
  7. 7. classpath:/

 3. spring.profiles.active

        springboot 默认是在src/main/resources文件夹中加载application.properties默认配置文件,格式为application-{profile}.properties,其中{profile}对应你的环境标识

     在application.properties中添加spring.profiles.active = dev,database

In addition to application.properties files, profile-specific properties can also be defined by using
the following naming convention: application-{profile}.properties . The Environment has a set of
default profiles (by default, [default] ) that are used if no active profiles are set. In other words, if
55 no profiles are explicitly activated, then properties from application-default.properties are
loaded.
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/157224
推荐阅读
相关标签
  

闽ICP备14008679号