SpringBoot的yml多環(huán)境配置
創(chuàng)建多個配置文件
application.yml #主配置文件
application-dev.yml #開發(fā)環(huán)境的配置
application-test.yml #測試環(huán)境的配置
在application.yml中添加多環(huán)境配置屬性
spring:
profiles:
active: @profiles.active@
項(xiàng)目啟動可能不會識別@,在pom.xml中設(shè)置filtering為true
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
</build>
在pom.xml中指定使用的配置
<profiles>
<profile>
<id>dev</id>
<activation>
<!-- 默認(rèn)激活-->
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<profiles.active>dev</profiles.active>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<profiles.active>test</profiles.active>
</properties>
</profile>
</profiles>
到此即為配置完畢,在maven->profiles下勾選動態(tài)激活需要使用的配置,想使用哪個配置勾選即可,其余的配置勾除,最后啟動項(xiàng)目使用的配置就是勾選的配置文件文章來源:http://www.zghlxwxcb.cn/news/detail-722056.html
參考文章:
https://blog.csdn.net/github_36665118/article/details/130555496文章來源地址http://www.zghlxwxcb.cn/news/detail-722056.html
到了這里,關(guān)于IDEA中SpringBoot項(xiàng)目的yml多環(huán)境配置的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!