学习mybatis逆向工程师时,运行java代码时出现了以下两点报错:
报错一:
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
意思是:mysql驱动类“com.mysql.jdbc.driver”已被弃用。需要换成新的驱动程序类’com.mysql.cj.jdbc.driver’。
解决方法:
如图,generatorConfig.xml文件是逆向工程的配置文件,找到<jdbcConnection>标签内容:
将驱动:
`driverClass="com.mysql.jdbc.Driver"`
改为:
driverClass="com.mysql.cj.jdbc.Driver"
报错二:
The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one
意思是数据库时区存在错误。
解决方案:
cmd命令进入数据库,输入以下两条命令:
show variables like '%time_zone%';
set global time_zone='+8:00';
执行结果: