springboot--多环境

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

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

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

java -jar xxx.jar --spring.profiles.active=dev
相关文章
相关标签/搜索