1. YAML配置文件注入法
yaml文件可以直接给实体类注入整个文件的值
- 在springboot项目中的resources目录下新建一个文件 application.yml
- pojo目录下创建实体类Dog和实体类Person
- Dog.java
@Component //注册bean到容器中
@Data
public class Dog {
private String name;
private Integer age;
}
- Person.java
@Component //注册bean到容器中
@Data
public class Person {
private String name;
private Integer age;
private Boolean happy;
private Date birth;
private Map<String,Object> maps;
private List<Object> lists;
<