该注解用于将yml设置的属性注入到bean中,方便使用
1、构建一个bean
@Component @ConfigurationProperties(prefix = "test") @Data public class TestYml { private String dogName; private String catName; }
2、yml文件中设置属性
test: dog-name: li5 catName: li6
3、输出testyml
TestYml(dogname=li5, catName=li6)
由上述知:bean的属性名会无视连接符‘-’,依旧会将dogName的属性注入 ,强啊。