springboot--多环境

在Spring Boot中多环境配置文件名需要满足application-{profile}.properties的格式,其中{profile}对应你的环境标识,比如:

  • application-dev.properties:开发环境
  • application-prod.properties:生产环境

想要使用对应的环境,只需要在application.properties中使用spring.profiles.active属性来设置,值对应上面提到的{profile},这里就是指dev、prod这2个。
当然你也可以用命令行启动的时候带上参数:

java -jar xxx.jar --spring.profiles.active=dev
原文地址:https://www.cnblogs.com/jentary/p/11043533.html