且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Spring Boot:如何使用多个yml文件

更新时间:2023-01-18 21:04:51

@PropertySource 不支持YAML(可能会在Spring 4.1中使用)。您可以将 spring.config.location spring.config.name 设置为以逗号分隔的列表(例如,作为系统属性或命令行参数)。

@PropertySource does not support YAML (probably it will in Spring 4.1). You can set spring.config.location or spring.config.name to a comma-separated list (e.g. as System property or command line argument).

我个人喜欢在同一个地方放置所有的YAML(结构真的有助于在视觉上分解它,你可以使用里面的文件文件将其拆分更多)。我觉得这只是味道。

Personally I like all my YAML in the same place (the structure really helps to break it up visually, and you can use documents inside the file to split it up more). That's just taste I guess.