springboot细节回顾(Springboot details review)

配置文件模块

.properties:目前官方不推荐,建议更换为yaml

  语法结构: key=value

.yaml:将yaml加载为将yaml加载为

YamlPropertiesFactoryBean
Properties,
YamlMapFactoryBean
Map,对空格要求极为严格

  语法结构:key:空格+value

##yaml

# 普通的key-value
name: tian

# 对象
student:
    name: tian
    age: 5

#行内写法
 student: {name: tian,age: 5}

# 数组
pets:
    - cat
    - dog
    - pig

pets: [cat,dog,pig]


##.properties   只能保存键值对

name=tian
student.name = tian
student.age = 5
————————

Profile module

. Properties: < / strong > it is not recommended by the official at present. It is recommended to replace it with yaml

< strong > syntax structure: key = value < / strong >

. Yaml: < / strong > Load yaml as load yaml as

YamlPropertiesFactoryBean
Properties,
YamlMapFactoryBean
Map,对空格要求极为严格

< strong > syntax structure: key: space + value < / strong >

##yaml

# 普通的key-value
name: tian

# 对象
student:
    name: tian
    age: 5

#行内写法
 student: {name: tian,age: 5}

# 数组
pets:
    - cat
    - dog
    - pig

pets: [cat,dog,pig]


##.properties   只能保存键值对

name=tian
student.name = tian
student.age = 5