spring-boot 再添加mysql啟動器的時候報錯, The driver is automatically registered via the SPI and manual loading of the driver class....


mysql驅動更新迭代之后驅動,稍微有點變化:

com.mysql.jdbc.Driver (變化為) --> driver-class-name: com.mysql.cj.jdbc.Driver

還有就是另一個報錯

The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration

這個是由於時區的問題,之前在SSM中 這樣寫是沒有問題的,

jdbc:mysql://127.0.0.1:3306/jtdb?useUnicode=true&characterEncoding=UTF-8


但是換spring boot之后,可能是自動匹配新版本的原因吧,導致的,更換為

jdbc:mysql://127.0.0.1:3306/jtdb?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
沒有問題了,
完整的yml配置數據庫的配置
spring:
datasource:
# driver-class-name: com.mysql.jdbc.Driver com.mysql.cj.jdbc.Driver
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: root
url: jdbc:mysql://127.0.0.1:3306/jtdb?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC

做個備忘,防止以后出現類似的問題,節省時間

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM