SpringBoot:.yml和.properties对赋值的不同

承接:SpringBoot:yml文件给变量赋值以及test的使用

比如在yml中给student赋值:

student:
  name: chen
  age: 23
  sex: true
  hobbies:  #hobbies是个数组,数组和list都用这种方法赋值,-后面要有空格
    - book
    - music
    - run
  location: {province: 贵州,city: 毕节,zone: 七星关区}  #map类型的写法
  skills:   #skills是个list
    - math
    - codding
    - running
  pet:
    name: hashiqi
    color: white

现在假如在.properties中给student的name和age赋值,那么格式为:

student.name = 张三
student.age = 24

其他地方不必做更改

发布了126 篇原创文章 · 获赞 7 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_36880027/article/details/104344767