在Mybatis连接数据库配置文件的时候报时区异常
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.
这是我的配置文件mybatis_generator.properties
jdbc.type=mysql
jdbc.driverClassName:com.mysql.cj.jdbc.Driver
jdbc.url:jdbc:mysql://127.0.0.1:3306/test_springboot?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true
jdbc.username=root
jdbc.password=linford
jdbc.pool.minIdle=8
jdbc.pool.maxActive=100
generator.classPath=D:\Develop\develop_jar\web\mysql-connector-java-5.1.30.jar
generator.mapperConfigFilename=mapper-config.xml
generator.targetProject=SpringBootDemo_Maven
generator.domainPackage=com.linford.bean
generator.mapperPackage=com.linford.mapper
generator.daoPackage=com.linford.dao
这是因为我的的mysql驱动版本是6.0以上的
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.6</version>
</dependency>
需要在jdbc.url那里添加“serverTimezone=UTC”不然会因为时区问题报错,这里用了CTT中国台湾时区避免产生8小时时差
修改后:
jdbc.url:jdbc:mysql://127.0.0.1:3306/test_springboot?serverTimezone=CTT&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true