@ConfigurationProperties("person") //或是prefix属性 @Component //必须注册成容器中的bean被容器管理起来 public class Person { private String name; private int age; private int sex;
private String firstName;
private String secondName;
get set }
1. application.yml
person: name: lisi age: 20 sex: 1
firstName
second-name 无论是驼峰还剩这种方式,都会被识别成驼峰标识的JavaBean属性
2. application.properties
person.name=xiaochao
person.age=10
person.sex=1