spring boot 配置 spring.config.location

1 . 2.x版本

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

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

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

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

2.  spring.config.additional-location

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

1. file:./custom-config/
2. classpath:custom-config/
3. file:./config/
4. file:./config/*/
5. file:./
6. classpath:/config/
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.
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值