从 @ConfigurationProperties 中删除位置属性
有哪些替代方案?
我以前一直这样使用它。
@ConfigurationProperties(locations = "a.yml")
最佳答案
同样的问题:我们在几个 yaml 文件上有数百个配置键,每个配置键都方便地映射到我们注入(inject)业务逻辑 bean 的 pojo。
我可以做的最好的事情是升级到 Spring Boot 1.5,同时保持我们的生产应用程序运行而无需太多重构,如下所述:http://fabiomaffioletti.me/blog/2016/12/20/spring-configuration-properties-handle-deprecated-locations/
或者,如果这对您不起作用,您可以尝试这种更简单的方式,即使需要更多重构(删除 @ConfigurationProperties 注释):http://fabiomaffioletti.me/blog/2017/02/09/spring-configuration-properties-locations-deprecation-another-approach/
关于spring-boot 从@ConfigurationProperties 中删除位置属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42083276/