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@
原文地址:https://www.cnblogs.com/mozq/p/12109059.html