Spring Boot 多环境配置

时间:2021-08-11 23:22:08

Spring Boot 多环境配置

在application.properties配置

spring.profiles.active=dev

application-dev.properties:开发环境
application-test.properties:测试环境
application-prod.properties:生产环境

Spring Boot 多环境配置

然后建立一个application-dev.properties

Spring Boot 多环境配置

我们现在来获取一下name的值
Spring Boot 多环境配置

Spring Boot 多环境配置

测试看看:
Spring Boot 多环境配置