SpringBoot多环境配置

可以从以下位置加载配置文件,优先级由高到低

Config locations are searched in reverse order. By default, the configured locations are classpath:/,classpath:/config/,file:./,file:./config/*/,file:./config/. The resulting search order is the following:

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

application.yml

#springboot多环境配置:可以选择激活哪一个配置文件
spring:
  profiles:
    active: dev  # 选择application-dev.yml环境

application-dev.yml

server:
  port: 8081  	#配置端口号

application-test.yml

server:
  port: 8082  	#配置端口号
posted @ 2022-08-08 16:52  z-laoyao  阅读(60)  评论(0编辑  收藏  举报