多个环境配置文件
在Spring Boot中多环境配置文件名需要满足application-{profile}.properties的格式,其中{profile}对应你的环境标识,比如:
application-test.properties:测试环境
server.port=8083
application-dev.properties:开发环境
server.port: 8081
application-prod.properties:生产环境
server.port=8082
想要使用对应的环境,只需要在application.properties中使用spring.profiles.active属性来设置,值就是{profile},如dev、prod。
spring.profiles.active=dev