package com.kuang.spring02config.pojo;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Component
@ConfigurationProperties(prefix = "person")
public class Person {
private String name;
private Integer age;
private Boolean happy;
private Date birth;
private Map maps;
private List
person:
name: shuji
age: 3
happy: false
birth: 2021/10/12
lists:
code
music
girl
dog:
name: 旺财
age: 3
package com.kuang.spring02config;
import com.kuang.spring02config.pojo.Dog;
import com.kuang.spring02config.pojo.Person;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class Spring02ConfigApplicationTests {
@Autowired
Dog dog;
@Autowired
Person person;
@Test
void contextLoads() {
System.out.println(person);
}
}