- properties配置格式
在Spring boot 中多环境配置文件名需要满足application-{profile}.properties的格式,其中{profile}对于你的环境标识,比如:
在application.properties 中配置 spring.profiles.active=dev #默认开发环境
在启动jar包时,使用命令行切换
-
java -jar xxx.jar --spring.profiles.active=test // 测试环境配置文件 java -jar xxx.jar --spring.profiles.active=prod// 生产环境配置文件