怎么读取springboot中的properties.yml配置文件里的配置值
test:username: name
主配置类中加上
@EnableConfigurationProperties(MailConfigProperties.class)
- 类上加@ConfigurationPropetise("test“),属性就会自动注入配置值;
@ConfigurationPropetise("test")
class Obj {
String username;// 自动注入配置值 name
}
- @Value(“test.username”)
class Obj {
@Value("test.username")
String username;// 自动注入配置值 name
}