springboot2.1以上配置的mysql的版本是8.x,和以前用的mysql5在配置上有點小區別,記錄一下
mysql5:
spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost:3306/mybatis_plus spring.datasource.username=root spring.datasource.password=123456
mysql8:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost:3306/mybatis_plus?serverTimezone=GMT%2B8 spring.datasource.username=root spring.datasource.password=123456
注意:
1、這里的 mysql8使用了 ?serverTimezone=GMT%2B8 后綴,因為Spring Boot 2.1 集成了 8.0版本的jdbc驅動,這個版本的 jdbc 驅動需要添加這個后綴,否則運行測驗用例報告如下錯誤:
java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more
2、兩者驅動的區別 ,在 jdbc 8 中 建議使用的驅動有cj,之前的 com.mysql.jdbc.Driver 已經被廢棄,否則運行測驗用例的時候會有 WARN 資訊
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/8279.html
標籤:Java
上一篇:問一下,在idea中,如果有一段前端代碼給我,但是那個專案特別大,前端頁面都幾十百多個,我怎么快速找到那段代碼所在的檔案
