自定义配置读取类
@Component
@PropertySource(value ="classpath:UserInfo.properties")
@ConfigurationProperties(prefix ="user")
@Data
public class User2 {
private Stringname1;
private int age1;
private Stringaddr1;
public StringtoString() {
return "User{" +
"name='" +name1 +'\'' +
", age=" +age1 +
", addr='" +addr1 +'\'' +
'}';
}
}
properties文件
user.name1=zzz
user.age1=100
user.addr1=LinYi