每个:
之后都要加一个空格不然无法识别
# 普通的key-value
name: pengge
# 对象
student:
name: pengge
age: 19
# 行内写法
student: {name: pengge,age: 19}
# 数组
pets:
- cat
- dog
pets: [cat,dag]
yaml文件可以直接给实体类赋值
通过注释的方式进行绑定
注意实体类属性对应
JSR303校验
springboot2.2以上需要自己导入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
JSP303校验使用方式
类上注释@Validated
对应属性上写对应的检验注释