•application.properties
•application.yml
person.last-name=\u674E\u56DB
person.age=12
person.birth=2017/12/15
person.boss=false
person.maps.k1=v1
person.maps.k2=14
person.lists=a,b,c
person.dog.name=dog
person.dog.age=15
1 通过@ConfigurationPropertie注入 :该注入适用于全局application.properties , @ConfigurationProperties:告诉SpringBoot将本类中的所有属性和配置文件中相关的配置进行绑定
@Component
@ConfigurationProperties(prefix = "person")
//@Validated
public class Person {
private String lastName;
private Integer age;
private Boolean boss;
private Date birth;
private Map<String,Object> maps;
private List<Object> lists;
private Dog dog;
// Set Get methods
}
2 通过@Value注入 ,该注入适用于全局application.properties
@Component
//@ConfigurationProperties(prefix = "person")
//@Validated
public class Pers