spring boot: ConfigurationProperties

读取配置信息

1.5 之前

@Component
@ConfigurationProperties(prefix = "user", locations= {"classpath:user.properties"})
public class UserConfig {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
private int age;
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}

1.5 之后

@Component
@PropertySource(value = { "classpath:user.properties" })
@ConfigurationProperties(prefix = "user")
public class UserConfig { private String username;
private Integer age;
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
上一篇:Exp2 后门原理与实践-------20164325王晓蕊


下一篇:Spring如何加载XSD文件(org.xml.sax.SAXParseException: Failed to read schema document错误的解决方法)