Spring Boot.配置二
一、多环境配置文件使用
1.多Profile文件使用
1)文件名规则:application-{profile}.properties

2)启用profile

3)dev配置信息

4)运行结果

2.使用yml程序块
1)使用三个横线写程序块

2)运行结果

二、多环境启用的几种方式
配置文件:

1.命令行参数设置
项目右键--->Run As--->Run Configurations

在Arguments中输入:
--spring.profiles.active=dev
运行结果:

2.VM参数设置

3.JAR参数设置
控制台运行:
java -jar springBootTest-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev
运行结果:

赞(1)
赏