(新)springboot2.x 新的属性绑定方式

在 Spring Boot 2.0 中,用于绑定Environment属性的机制@ConfigurationProperties已经完全彻底修改。我们借此机会收紧了松散绑定的规则,并修复了 Spring Boot 1.x 中的许多不一致之处。

新的BinderAPI 也可以@ConfigurationProperties直接在你自己的代码之外使用。例如,下面将结合到List的PersonName对象:

List people = Binder.get(environment).bind("my.property", Bindable.listOf(PersonName.class)).orElseThrow(IllegalStateException::new);

你可能感兴趣的:((新)springboot2.x 新的属性绑定方式)