SpringBoot - Yaml语法
测试用到的类:
类的属性必须重写Get与Set方法 不管属性是私有的还是公共的,必须重写Get与Set方法
@Component @ConfigurationProperties(prefix = "student") public class Student { //基本数据类型 byte data1; short data2; int data3; long data4; float data5; double data6; char data7; boolean data8; //引用数据类型 Body data9; String data10; //数组类型 int[] data11; Body[] data12; //集合 List<Integer> data13; List<Body> data14; Map<String,Integer> data15; Map<String,Body> data16; } class Body{ String likeFood; int balance; }
Yaml
student: data1: 10 data2: 20 data3: 30 data4: 40 data5: 50.10 data6: 60.20 data7: 我 data8: true data9: {likeFood: 披萨,balance: 200.10} data10: 我你她 data11: [1,2,3,4] data12: [{likeFood: 披萨,balance: 200.10},{likeFood: 披萨,balance: 200.10}] data13: - 1 - 2 - 3 data14: - {likeFood: 披萨,balance: 200.10} - {likeFood: 披萨,balance: 200.10} - {likeFood: 披萨,balance: 200.10} data15: key1: 1 key2: 2 key3: 3 data16: key1: {likeFood: 披萨,balance: 200.10} key2: {likeFood: 披萨,balance: 200.10} key3: {likeFood: 披萨,balance: 200.10}
posted on 2022-12-20 19:42 Mikasa-Ackerman 阅读(19) 评论(0) 编辑 收藏 举报