【发布时间】:2019-12-01 20:02:20
【问题描述】:
我有 custom.yaml 文件的内容:
refill-interval-millis: 1000
endpoints:
- path: /account/all
rate-limit: 10
- path: /account/create
rate-limit: 20
和我的班级阅读该文件:
@Component
@PropertySource("classpath:custom.yaml")
@ConfigurationProperties
public class Properties {
private int refillIntervalMillis;
private List<Endpoint> endpoints = new ArrayList<>();
// getters/setters
public static class Endpoint {
private String path;
private int rateLimit;
// getters/setters
}
}
所以,当我运行我的代码时,refillIntervalMillis 设置正确,但endpoints 列表为空。拿不到为什么?
【问题讨论】: