亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

IDEA中SpringBoot項目的yml多環(huán)境配置方式

 更新時間:2023年10月26日 15:02:40   作者:黎明曉月  
這篇文章主要介紹了IDEA中SpringBoot項目的yml多環(huán)境配置,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友參考下吧

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@

項目啟動可能不會識別@,在pom.xml中設置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>
                <!--  默認激活-->
                <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)激活需要使用的配置,想使用哪個配置勾選即可,其余的配置勾除,最后啟動項目使用的配置就是勾選的配置文件

在這里插入圖片描述

參考文章:https://blog.csdn.net/github_36665118/article/details/130555496

到此這篇關(guān)于IDEA中SpringBoot項目的yml多環(huán)境配置的文章就介紹到這了,更多相關(guān)idea springboot多環(huán)境配置內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論