1) SpringBoot特點(diǎn)
- 特點(diǎn):約定優(yōu)于配置
2) YAML配置文件
-
語法特點(diǎn):
- 大小寫敏感
- 使用空格縮進(jìn)表示層級關(guān)系
- 縮進(jìn)的空格數(shù)目沒有要求,同級元素左側(cè)對齊即可
- 使用 # 注釋削咆,只有行注釋熬词,沒有塊注釋
- key 與 value 用 : 加上空格來分割
-
基本組件
- 對象(映射/字典)
- 數(shù)組(列表)
# 對象
person:
name: LC
age: 25
# 數(shù)組
- a
- b
- 支持的數(shù)據(jù)類型
# 字符串
string: hello
# 布爾值
boolean: true
# 數(shù)值(整型挽懦、浮點(diǎn))
number: 123
# Null
null: ~
# 日期時(shí)間(Date肠虽、Time)
date: 2019-06-09
- SpringBoot常用配置
spring:
# 數(shù)據(jù)源配置
datasource:
type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://127.0.0.1:3306/spring_boot
username: root
password: 123456
driver-class-name: com.mysql.jdbc.Driver
name: druid
druid:
# 初始化大小,最小罪帖,最大
initialSize: 5
minIdle: 5
maxActive: 20
# 配置獲取連接等待超時(shí)的時(shí)間
maxWait: 60000
# 配置間隔多久才進(jìn)行一次檢測躁劣,檢測需要關(guān)閉的空閑連接迫吐,單位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一個(gè)連接在池中最小生存的時(shí)間,單位是毫秒
minEvictableIdleTimeMillis: 300000
# http請求
http:
#json序列化框架
converters:
preferred-json-mapper: fastjson
#上傳文件账忘、請求最大限制
multipart:
max-file-size: 50MB
max-request-size: 50MB
# Spring MVC配置
mvc:
dispatch-options-request: true
static-path-pattern: /**
# 激活環(huán)境配置
profiles:
active: local
# Redis配置
redis:
host: 127.0.0.1
port: 6379
# 應(yīng)用名
application:
name: springboot
# Redis客戶端
jedis:
pool:
host: 127.0.0.1
port: 6379
# 線程池的配置文件
threads:
pool:
queueCapacity: 50
corePoolSize: 20
maxPoolSize: 50
keepAliveSeconds: 600
# 日志級別
logging:
level: info
# Web服務(wù)器
server:
# 超時(shí)時(shí)間
session:
timeout: 60
# 端口
port: 8080
# 根路徑
context-path: /springboot