多环境配置

多环境配置的优先级

image-20250118222014060

使用方式

properties文件

1.一个文件对应一个环境

2.在application.properties文件中指定你使用的那个文件

image-20250119110355738

yaml文件

单文件激活

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
spring:
profiles:
active: dev

---
server:
port: 8084
spring:
config:
activate:
on-profile: test
---
server:
port: 8085
spring:
config:
activate:
on-profile: dev

多文件

类比那个properties即可