配置文件值映射到类属性 发表于 2022-03-20 分类于 编程 文章字数:52,阅读全文大约需要1分钟 相比于@Value这个方法更加简便一点 person.properties 123person: lastName: hello age: 18 12345678910111213// 1. 引入配置文件@PropertySource(value = {"classpath:person.properties"})@Component// 2. 加载开头为person的@ConfigurationProperties(prefix = "person")public class Person { // 3. 属性和配置文件的值对应 private String lastName; private Integer age;...