- @ConfigurationPropertiesBinding用于声明自定义是配置解析类,作用于方法上
- 自定义解析类需要实现接口Converter,然后使用@ConfigurationPropertiesBinding注解修饰
示例
- User.java
Public class User{ private String name; private iint age; … } |
- UserConverter.java
@Component @ConfigurationPropertiesBinding public class UserConverter implements Converter<String, User> { @Override public User convert(String source) { return JSONObject.parseObject(source, User.class); } } |
|