相比于
@Value
这个方法更加简便一点
person.properties
person:
lastName: hello
age: 18
// 1. 引入配置文件
@PropertySource(value = {"classpath:person.properties"})
@Component
// 2. 加载开头为person的
@ConfigurationProperties(prefix = "person")
public class Person {
// 3. 属性和配置文件的值对应
private String lastName;
private Integer age;
...