SpringBoot數據源配置--驅動版本與時區注意

數據源配置注意點

1、驅動選擇區別:com.mysql.cj.jdbc.Driver、com.mysql.jdbc.Driver

2、時區注意:serverTimezone=GMT%2B8

時區不配置,可能導致異常(因爲mysql默認使用的是美國時間,比中國早8個小時):

java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone

 

我的配置

#數據源配置
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/essm?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false
spring.datasource.username=root
spring.datasource.password=###

 

具體更多細節參考:https://www.cnblogs.com/qubo520/p/8483595.html 這篇文章

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章