1.配置文件名称,配置文件名必须满足application-{profile}.properties的格式:
application-dev.properties
application-prod.properties
application-test.properties
①创建配置文件并设置端口:
application-dev.properties //开发环境配置文件
application-test.properties //测试环境配置文件
application-prod.properties //生产环境配置文件
②在全局配置文件application.properties中激活环境的属性:
Spring.profiles.active=dev //激活开发环境配置文件
Spring.profiles.active=test //激活测试环境配置文件
Spring.profiles.active=prod //激活生产环境配置文件