springboot配置多個yml文件


springboot配置多個yml文件

參考

springboot配置多個yml文件

maven(三)最詳細的profile的使用

實戰

為生產和開發分別配置一個profile。每個都有多個文件。

profile

每個profile都應該有唯一的id, 可以同時激活多個profile,每個profile提供一些配置信息。

<project>
    <profiles>
        <!-- profile的id應該唯一,但是當重復時,使用的是文件后面的配置。-->
        <profile>
            <id>dev</id>
            <properties>
                <spring.profiles.active>prod,prod-wechat</spring.profiles.active>
            </properties>
        </profile>
        <profile>
            <id>prod</id>
            <activation>
                <!--默認激活-->
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <spring.profiles.active>dev,wechat</spring.profiles.active>
            </properties>
        </profile>
    </profiles>
</project>
# application.yml文件
spring:
  profiles:
    active: @spring.profiles.active@
# application-prod-wechat.yml文件
xhpay:
    front: prod-wechat
# application-wechat.yml文件
xhpay:
    front: wechat

bugs

Caused by: org.yaml.snakeyaml.scanner.ScannerException: while scanning for the next token
found character '@' that cannot start any token. (Do not use @ for indentation)
 in 'reader', line 4, column 13:
        active: @spring.profiles.active@


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM