【Spring Boot】(3)、配置文件

1、Spring Boot使用全局的配置文件,默认文件名为application,且固定。

  • application.properties

  • application.yml

配置文件的作用:修改Spring Boot自动配置的默认值。


2、YAML语法

server:
  port: 8081
  path: /hello
	
person:
  name: zhangsan
  age: 20
  boss: false
  birth: 2017/11/12
  #map写法1:行内
  maps1: {k1: v1, k2: v2}
  #map写法2
  maps2:
    k3: v3
    k4: v4
  #数组写法1
  lists1: 
    - l1
    - l2
  #数组写法2:行内
  lists2: [l3, l4]
  # 对象
  dog:
    name: 小狗
    age: 2

熟悉基本的yaml语法即可,至于其他复杂的语法,可以在需要使用的时候查看官方文档即可。



====================打个广告,欢迎关注====================

QQ:
412425870
微信公众号:Cay课堂

csdn博客:
http://blog.csdn.net/caychen
码云:
https://gitee.com/caychen/
github:
https://github.com/caychen

点击群号或者扫描二维码即可加入QQ群:

328243383(1群)




点击群号或者扫描二维码即可加入QQ群:

180479701(2群)




猜你喜欢

转载自blog.csdn.net/caychen/article/details/79967566