Springboot的yml配置文件用法
更新時(shí)間:2023年03月17日 15:03:47 作者:茂桑
這篇文章主要介紹了Springboot的yml配置文件用法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
一、服務(wù)配置
server:
port: 8989
servlet:
# context-path就是端口號(hào)與服務(wù)之間要加的一段路徑,比如localhost:8080/wcm/login/login的/wcm就是
context-path: /
二、數(shù)據(jù)庫連接
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/jxc_manage?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: root
password: root
# 數(shù)據(jù)庫連接池
hikari:
# 連接池名
pool-name: DateHikariCP
# 最小空閑連接數(shù)
minimum-idle: 5
# 空閑連接存活最大時(shí)間,默認(rèn)600000(10分鐘)
idle-timeout: 180000
# 最大連接數(shù),默認(rèn)10
maximum-pool-size: 10
# 從連接池返回的連接的自動(dòng)提交
auto-commit: true
# 連接最大存活時(shí)間,0表示永久存活,默認(rèn)1800000(30分鐘)
max-lifetime: 1800000
# 連接超時(shí)時(shí)間,默認(rèn)30000(30秒)
connection-timeout: 30000
# 測試連接是否可用的查詢語句
connection-test-query: SELECT 1
## freemarker
freemarker:
suffix: .ftl
content-type: text/html
charset: UTF-8
template-loader-path: classpath:/views/
request-context-attribute: ctx
settings:
number_format: 0.##
三、Mybatis-Plus
# Mybatis-plus配置
mybatis-plus:
#配置Mapper映射文件
mapper-locations: classpath*:/mapper/*Mapper.xml
# 配置MyBatis數(shù)據(jù)返回類型別名(默認(rèn)別名是類名)
type-aliases-package: com.lzj.admin.pojo
configuration:
# 自動(dòng)駝峰命名
map-underscore-to-camel-case: true
四、日志打印
## SQL 打印(方法接口所在的包,不是Mapper.xml所在的包)
logging:
# 日志級(jí)別
level:
com.lzj.admin.mapper: debug
## 控制臺(tái)日志輸出格式
pattern:
console: '%d{2100-01-01 13:14:00.666} [%thread] %-5level %logger{50} - %msg%n'
五、Redis
#redis集群
spring:
redis:
host: 127.0.0.1
port: 6379
timeout: 20000
# 集群環(huán)境打開下面注釋,單機(jī)不需要打開
# cluster:
# 集群信息
# nodes: xxx.xxx.xxx.xxx:xxxx,xxx.xxx.xxx.xxx:xxxx,xxx.xxx.xxx.xxx:xxxx
# #默認(rèn)值是5 一般當(dāng)此值設(shè)置過大時(shí),容易報(bào):Too many Cluster redirections
# maxRedirects: 3
pool:
max-active: 8
min-idle: 0
max-idle: 8
max-wait: -1
password:
附:yml基礎(chǔ)語法

總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
SpringBoot整合Dubbo框架,實(shí)現(xiàn)RPC服務(wù)遠(yuǎn)程調(diào)用
Dubbo是一款高性能、輕量級(jí)的開源Java RPC框架,它提供了三大核心能力:面向接口的遠(yuǎn)程方法調(diào)用,智能容錯(cuò)和負(fù)載均衡,以及服務(wù)自動(dòng)注冊(cè)和發(fā)現(xiàn)。今天就來看下SpringBoot整合Dubbo框架的步驟2021-06-06
Spring Boot集成Redis實(shí)現(xiàn)緩存機(jī)制(從零開始學(xué)Spring Boot)
這篇文章主要介紹了Spring Boot集成Redis實(shí)現(xiàn)緩存機(jī)制(從零開始學(xué)Spring Boot),需要的朋友可以參考下2017-04-04
SpringBoot的10個(gè)參數(shù)驗(yàn)證技巧分享
參數(shù)驗(yàn)證很重要,是平時(shí)開發(fā)環(huán)節(jié)中不可少的一部分,但是我想很多后端同事會(huì)偷懶,干脆不錯(cuò),這樣很可能給系統(tǒng)的穩(wěn)定性和安全性帶來嚴(yán)重的危害,那么在Spring Boot應(yīng)用中如何做好參數(shù)校驗(yàn)工作呢,本文提供了10個(gè)小技巧,需要的朋友可以參考下2023-09-09

