项目场景:
使用mybatis-generator插件逆向生成相关文件出现Failed to execute goal org.mybatis.generator:mybatis-generator-m报错问题
问题描述
Failed to execute goal org.mybatis.generator:mybatis-generator-maven-plugin:
1.3.0:generate (default-cli) on project MyBatis_demo4: 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.
原因分析:
1、mysql6.x版本或以上driverClass需加上.cj
jdbc.driver=com.mysql.cj.jdbc.Driver
2、在generatorConfig.xml配置文件中需要在connectionURL中加入中国标准时间时区信息
jdbc:mysql://localhost:3306/mybatis?serverTimezone=Asia/Shanghai
<!--配置数据库的连接信息-->
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/mybatis?serverTimezone=Asia/Shanghai"
userId="root"
password="123456">
</jdbcConnection>
再次运行mybatis-generator插件就成功啦!