在Spring Boot中多環(huán)境配置文件名需要滿足application-{profile}.properties的格式,其中{profile}對(duì)應(yīng)你的環(huán)境標(biāo)識(shí),比如:
- application-dev.properties:開發(fā)環(huán)境
- application-test.properties:測(cè)試環(huán)境
- application-pro.properties: 生產(chǎn)環(huán)境
至于哪個(gè)具體的配置文件會(huì)被加載,需要在application.properties文件中通過spring.profiles.active屬性來設(shè)置,其值對(duì)應(yīng){profile}值。

image.png
application.yml
spring:
profiles:
active: dev
application-dev.yml
variable:
profiles : dev
application-pro.yml
variable:
profiles : pro
application-test.yml
variable:
profiles : test