日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

yml文件配置mysql表大小写_springboot常用配置(yml文件)

發布時間:2023/12/15 数据库 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 yml文件配置mysql表大小写_springboot常用配置(yml文件) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

(1)端口服務配置

server:

port: 8080 #端口號

servlet:

context-path: /main #項目訪問路徑

(2)數據庫配置

spring:

datasource:

driver-class-name: com.mysql.jdbc.Driver

url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8&useSSL=false

username: root

password: root

jpa:

hibernate:

ddl-auto: update

show-sql: true

redis:

database: 0

host: localhost

port: 6379

password:

jedis:

pool:

max-active: 8

max-wait: -1

max-idle: 8

min-idle: 0

timeout: 0

(3)配置多個不同的profile,實現在不同的環境(比如開發、測試和生產環境)使用不同的配置變量。

# 默認的profile為dev,其他環境通過指定啟動參數使用不同的profile,比如:

# 測試環境:java -jar my-spring-boot.jar --spring.profiles.active=test

# 生產環境:java -jar my-spring-boot.jar --spring.profiles.active=prod

spring:

profiles:

active: dev

---

# 開發環境配置

spring:

profiles: dev

mysql:

ipPort: localhost:3306

---

# 測試環境配置

spring:

profiles: test

mysql:

ipPort: ip:port

---

# 生產環境配置

spring:

profiles: prod

mysql:

ipPort: ip:port

使用方法:

通過指定啟動參數使用不同的profile

測試環境: java -jar my-spring-boot.jar --spring.profiles.active=test

生產環境: java -jar my-spring-boot.jar --spring.profiles.active=prod

在配置文件中指定 spring.profiles.active=dev

虛擬機參數

?-Dspring.profiles.active=dev

springboot 啟動會掃描以下位置的application.properties或者application.yml文件作為Spring boot的默認配置文件

–file:./config/

–file:./

–classpath:/config/

–classpath:/

優先級由高到底,高優先級的配置會覆蓋低優先級的配置

SpringBoot會從這四個位置全部加載主配置文件,互補配置;

項目打包好以后,我們可以使用命令行參數的形式,啟動項目的時候來指定配置文件的新位置;指定配置文件和默認加載的這些配置文件共同起作用形成互補配置;

java -jar spring-boot-02-config-02-0.0.1-SNAPSHOT.jar --spring.config.location=G:/application.properties

(4)指定靜態資源路徑

spring:

resources:

#指定靜態資源路徑,默認為classpath:[/META-INF/resources/,/resources/, /static/, /public/]以及context:/

static-locations: classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/}

(5)熱部署

在Springboot+Thymeleaf的開發過程中,默認情況下修改到任何代碼都需要重新啟動項目才能生效。使用spring.thymeleaf.cache和devtools來解決html熱啟動的問題

首先在pom.xml中配置

org.springframework.boot

spring-boot-devtools

runtime

true

注意:true只有設置為true時才會熱啟動,即當修改了html、css、js等這些靜態資源后不用重啟項目直接刷新即可。

然后修改application.yml

#熱部署--靜態資源立即生效

spring:

#熱部署--靜態資源立即生效

thymeleaf:

cache: false #是否開啟模板緩存,默認true

encoding: UTF-8 #指定模板的編碼,默認為: UTF-8

mode: HTML #指定模板的模式,具體查看StandardTemplateModeHandlers,默認為: HTML5

prefix: classpath:/templates/ #前綴

suffix: .html #后綴

check-template-location: true #是否檢查模板路徑是否存在,默認true

servlet:

content-type: text/html #響應類型,指定Content-Type,默認為: text/html

#熱部署生效

devtools:

restart:

enabled: true

(6)時間配置

spring:

jackson:

#指定日期格式,比如yyyy-MM-dd HH:mm:ss

date-format: yyyy-MM-dd HH:mm:ss

#指定日期格式化時區

time-zone: GMT+8

(7)模板配置

springboot 中自帶的頁面渲染工具為thymeleaf 還有freemarker 這兩種模板引擎 。

org.springframework.boot

spring-boot-starter-freemarker

spring:

freemarker:

suffix: .html #設定模板的后綴

request-context-attribute: request #request訪問request

content-type: text/html

enabled: true

cache: false #緩存配置

template-loader-path: classpath:/templates/ #模板加載路徑 按需配置

charset: UTF-8 #編碼格式

settings:

number_format: '0.##' #數字格式化,無小數點

(8)redis和shiro配置

org.springframework.boot

spring-boot-starter-data-redis

org.apache.shiro

shiro-spring

1.3.2

spring:

redis:

database: 0

host: localhost

port: 6379

password:

jedis:

pool:

max-active: 8

max-wait: -1

max-idle: 8

min-idle: 0

timeout: 0

shiro:

conf:

domain:

cookiePath: /

successUrl: /index

loginView: /login

openToken: false

sessionTimeout: 1800000

algorithmName: md5

hashIterations: 5

#不攔截的路徑

sysanon:

- /login

- /regist

#跨域配置

allowedOrigins:

- /**

總結

以上是生活随笔為你收集整理的yml文件配置mysql表大小写_springboot常用配置(yml文件)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。