一、环境配置的位置以及优先级


二、多环境切换
application.properties方式:
# springboot的多环境配置,可以选择激活哪一个配置文件
spring.profiles.active = test #-后面的
# 使用application-test.properties配置文件
application.yaml方式:
server:
port: 8081
spring:
profiles:
active: dev
---
server:
port: 8082
spring:
profiles: dev
---
server:
port: 8083
spring:
profiles: test
本文详细介绍了SpringBoot中环境配置的位置和优先级,以及如何通过application.properties和application.yaml实现多环境切换。例如,设置spring.profiles.active来激活test环境,使用不同的端口配置(如8082、8083)区分dev和test环境。
2014

被折叠的 条评论
为什么被折叠?



