美文网首页
springboot多环境配置两种方式

springboot多环境配置两种方式

作者: 只想做个俗人_贪财_好色 | 来源:发表于2019-07-25 13:55 被阅读0次

第一种就是springboot中默认的application.yml中添加
spring:
profiles:
active: 环境名
在application.yml同级目录中创建 application-环境名.yml 即可。
另外一种是通过maven
同样在application.yml 添加
spring:
profiles:
active: @env@
注意@@
另外在pom中添加

<profiles>
<profile>
<id>local</id>
<properties>
<env>local</env>
</properties>
<activation>

<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>dev</id>
<properties>
<env>dev</env>
</properties>
</profile>
</profiles>
我这里是添加了两个环境 local 、dev
注意要添加

<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
可能会有找不到 yml 情况

相关文章

网友评论

      本文标题:springboot多环境配置两种方式

      本文链接:https://www.haomeiwen.com/subject/cpchrctx.html