SpringBoot(8) —— yaml给对象属性赋值的几种方式

时间:2025-02-13 14:41:11
package com.thhh.pojo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.Date; import java.util.List; import java.util.Map; @Component public class Person { private String name; private Integer age; private boolean happy; private Date birth; private Map<String,Object> map; private List<Object> list; @Autowired private Dog dog; public Person() { } public Person(String name, Integer age, boolean happy, Date birth, Map<String, Object> map, List<Object> list, Dog dog) { this.name = name; this.age = age; this.happy = happy; this.birth = birth; this.map = map; this.list = list; this.dog = dog; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Integer getAge() { return age; } public void setAge(Integer age) { this.age = age; } public boolean isHappy() { return happy; } public void setHappy(boolean happy) { this.happy = happy; } public Date getBirth() { return birth; } public void setBirth(Date birth) { this.birth = birth; } public Map<String, Object> getMap() { return map; } public void setMap(Map<String, Object> map) { this.map = map; } public List<Object> getList() { return list; } public void setList(List<Object> list) { this.list = list; } public Dog getDog() { return dog; } public void setDog(Dog dog) { this.dog = dog; } @Override public String toString() { return "Person{" + "name='" + name + '\'' + ", age=" + age + ", happy=" + happy + ", birth=" + birth + ", map=" + map + ", list=" + list + ", dog=" + dog + '}'; } }