多环境配置的目录及优先级

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

可以选择激活哪一个文件

properties
如果配置文件都是一个优先级,命名方式为application-dev-properties,
可以使用spring.properties.active=dev来指定使用这个配置文件
yaml

---
server:
  port: 8081
spring:
  profiles: dev

---
server:
  port: 8082
spring:
  profiles: test 

---
server:
  port: 8083
spring:
  profiles:
    active: dev

直接使用- - -就可以分割了
用的话直接propertie:active来指定使用哪个

自定义配置

配置文件中能配置的东西,都有一个固有的规律
xxxAutoConfiguration都有一个默认值,都会有xxxProperties文件,这个文件和配置文件绑定,就可以使用我们自定义的配置
图片说明