1、@Component 将类注入到 SpringBoot 容器
@Component
@PropertySource("classpath:config.properties")
//属性前缀
@ConfigurationProperties(prefix = "project")
@Data
public class Config {
private String test;
private String test1;
}
2、@Value(“XXX”) 获取属性值,定义变量
@Value("${project.test}")
private String test;
ResourceBundle bundle = ResourceBundle.getBundle("config");
//
String test= bundle.getString("属性");