最近在学习mybatis,初学想仿照示例写个“helloworld”式的简单程序,结果第一次运行就出现一堆错误,但是代码我全是照着示例敲的,也检查过了,并没有出现代码上的错误。无奈只得一个一个百度。
错误1:
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.
其实这个不能算是错误,只是MySQL8.0的一个改变,如提示所说不推荐使用
解决办法:
将数据库驱动变更为com.mysql.cj.jdbc.Driver
。
错误2:
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.
从英文上翻译过来的意思就是时区出现问题了,好吧,网上百度了一下,解决办法如下。
解决办法:
在连接数据库的URL后面加上?serverTimezone=UTC
例如"jdbc:mysql://127.0.0.1:3306/edu?serverTimezone=UTC"