springboot_yaml与properties区别

application.properties

## springboot这个配置文件可以配置什么的东西呢?

## 第一种:背官方的配置,呜呜呜太多了

## 然后,官方推荐视图.yaml代替.properties

# key=value,只能保存键值对

name=fan

student.name =fan
student.age=18

application.yaml

# key:空格value,对于空格的要求十分严格

# 可以注入到配置类中

# 普通的key,value
name: fan

# 对象
student:
  name: fan
  age: 18

# 行内写法
student1: {name: fan, age: 18}

# 数组
pets:
  - cat
  - dog
  - pig

pets1: [cat,dog,pig]

两种配置文件格式都可以被springboot识别;

posted @ 2023-01-10 13:57  Fannaa  阅读(23)  评论(0)    收藏  举报