1.先建一个use(例如)
2.在这个类上加上
@ConfigurationProperties(prefix = "user")
@Component
@Component注解表明是组件,可被自动发现,@ConfigurationProperties注解之前是location属性表明配置文件位置,prefix表示读取的配置信息的前缀
prefix的值就是你在yaml文件写的类名。
3.yaml中对应类的写法:
要求 属性对应。
1.先建一个use(例如)
2.在这个类上加上
@ConfigurationProperties(prefix = "user")
@Component
@Component注解表明是组件,可被自动发现,@ConfigurationProperties注解之前是location属性表明配置文件位置,prefix表示读取的配置信息的前缀
prefix的值就是你在yaml文件写的类名。
3.yaml中对应类的写法:
要求 属性对应。