文章目录
SpringBoot使用@PropertySource获取properties配置信息新建Properties文件编写对应的类测试
SpringBoot使用@PropertySource获取properties配置信息
新建Properties文件
编写对应的类
@Component
@ConfigurationProperties(prefix
= "test")
@PropertySource("classpath:test.properties")
public class TestProperties {
private String content
;
public String
getContent() {
return content
;
}
public void setContent(String content
) {
this.content
= content
;
}
}
@ConfigurationProperties 配置文件内容的前缀 @PropertySource 对应的是配置文件的位置
测试