使用Mybatis逆向工程时报错:java.sql.SQLException: Unknown system variable ‘query

使用Mybatis逆向工程时报错:java.sql.SQLException: Unknown system variable ‘query,第1张

使用Mybatis逆向工程时报错:java.sql.SQLException: Unknown system variable ‘query

使用Mybatis逆向工程创建javaBean、dao以及相应的映射mapper文件时报错:
Unknown system variable 'query_cache_size’

原因是mysql-connecter-java的版本过低,是数据库驱动程序与数据库版本不对应,根据官方的说法是 :
The query cache is deprecated as of MySQL 5.7.20, and is removed in MySQL 8.0. Deprecation includes query_cache_size.
意思是query cache在MySQL5.7.20就已经过时了,而在MySQL8.0之后就已经被移除了。
将maven依赖的jar包改成更高版本的:


            mysql
            mysql-connector-java
            8.0.11
        

运行后报错:
java.sql.SQLException: 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 property) to use a more specifc time zone value if you want to utilize time zone support.

是因为jdbcUrl的时区未设置,原url为:

jdbc.jdbcUrl=jdbc:mysql://localhost:3306/ssm_crud?useUnicode=true&characterEncoding=utf-8

修改为:

jdbc.jdbcUrl=jdbc:mysql://localhost:3306/ssm_crud?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC

运行报错:
javax.net.ssl.SSLException: closing inbound before receiving peer’s close_notify

解决方法:在配置文件中,配置连接数据库的url时,加上useSSL=false

修改后的url:

```c
jdbc.jdbcUrl=jdbc:mysql://localhost:3306/ssm_crud?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC&useSSL=false

最后运行成功,不报错!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5719508.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-18
下一篇 2022-12-18

发表评论

登录后才能评论

评论列表(0条)

保存