1.3K Star 6.1K Fork 2.9K

GVP季圣华 / 华夏ERP

 / 详情

无法连接 MySQL8,请将mysql-connector-java版本更新为8.x

Backlog
Opened this issue  
2021-01-05 15:02

现在项目中mysql-connector-java的版本是5.x,连接MySQL8时会抛npe,请将其版本更新为8.x,并去掉配置文件中的spring.datasource.driverClassName

Comments (3)

YangHeng created任务
YangHeng set related repository to 季圣华/华夏ERP
展开全部操作日志

这样会导致5.7版本的出问题吧

Connector/J 8.0 is a Type 4 pure Java JDBC 4.2 driver for the Java 8 platform. It provides compatibility with all the functionality of MySQL 5.6, 5.7, and 8.0. See MySQL Connector/J 8.0 Developer Guide for details.

MySQL Connector/J 8.0 is highly recommended for use with MySQL Server 8.0, 5.7, and 5.6. Please upgrade to MySQL Connector/J 8.0.

https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-versions.html

官网文档写的,没试5.7

说一下我的解决办法吧

  1. 首先用BandiZip打开lib目录中的jshERP.jar,进入BOOT-INF/lib中删除原来的mysql-connector-java-5.x.jar
  2. 然后点击工具栏的添加,选择mysql-connector-java-8.x.jar,注意压缩方式要选择不压缩,然后保存
  3. 注释掉配置文件中的 spring.datasource.driverClassName,让程序自动选择驱动
  4. 由于项目的SQL写法不完全兼容 MySQL 8,需要调整sql_mode。在spring.datasource.url的配置最后面追加&sessionVariables=sql_mode='TRADITIONAL,ALLOW_INVALID_DATES',将sql_mode设置为传统模式,并且允许使用非法日期值

如此一来,基本上就能正常运行了

YangHeng translation missing: en.project.new_issues_operate_log.link_issue(Normal)SQL查询的结束日期错误

Sign in to comment

状态
Assignees
Milestones
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
Branches
Planed to start   -   Planed to end
-
Top level
Priority
参与者(2)
852955 jishenghua 1578933912 354044 yangheng work 1578921165
Java
1
https://gitee.com/jishenghua/JSH_ERP.git
git@gitee.com:jishenghua/JSH_ERP.git
jishenghua
JSH_ERP
华夏ERP

Search