yaml数据格式
- 数据前面要用空格与冒号隔开
# 端口号
server:
port: 8080
# 数据前面要用空格与冒号隔开
country: china
province: beijing
city: beijing
area: haidian
party: true
birthday: 2023-10-01
likes:
- game
- music
- sleep
us:
- name: cencen
age: 18
- name: lielie
age: 20
users2: [{},{}]
读取数据
- 使用@Value读取单个数据
- 属性名引用方式:
${一级属性名.二级属性名}
//读取yaml数据中的单一数据
@Value("${country}")
private String country1;
@Value("${server.port}")
private String port1;
@Value("${likes[1]}")
private String likes1;
@Value("${us[1].age}")
private String age1;
标签:beijing,String,age,private,Value,yml,likes
From: https://www.cnblogs.com/CenCen/p/17284438.html