Configuration and use of SpringBoot yaml

application.yml is configured as follows

person:
    lastName: hello
    age: 18
    boss: false
    birth: 2017/12/12
    maps: {k1: v1,k2: 12}
    lists:
      - lysis
      ‐ zhaoliu
    dog:
      name: puppy
      age: 12

 The javaBean configuration is as follows:

@Component
@ConfigurationProperties(prefix "person")
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;

rely

<!‐‐Import the configuration file processor, there will be a prompt when the configuration file is bound‐‐>
<dependency>        
<groupId>org.springframework.boot</groupId>            
<artifactId>spring‐boot‐configuration‐processor</artifactId>            
<optional>true</optional>            
</dependency> 

k: (space) v: represents a pair of key-value pairs (spaces must be present);

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325231550&siteId=291194637