在我的 Spring Cloud Config yaml 文件中,我可以使用序列吗?我想将 yaml 序列映射到 Java ArrayList 并注入(inject)值。

一个例子是这样的。

YAML 文件:

american:
  - Boston Red Sox
  - Detroit Tigers
  - New York Yankees

Java Spring Bean:
@Value("${american}")
List<String> american;

最佳答案

这只是 Spring Boot 的一个特性:http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-loading-yaml

它显示了 yaml 列表的示例。

关于spring-boot - Spring Cloud Config 是否支持读取 yaml 序列?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28243141/

10-12 00:21
查看更多