springboot配置多個yml文件
參考
實戰
為生產和開發分別配置一個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@