使用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包改成更高版本的:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.11</version>
</dependency>
运行后报错:
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
最后运行成功,不报错!

本文解决Mybatis逆向工程中遇到的错误,包括因mysql-connector-java版本过低导致的问题,以及如何正确配置时区和SSL来避免运行时出现的SQLException。

被折叠的 条评论
为什么被折叠?



