mybatis-generator:generate failed: Exception getting JDBC Driver: com.mysql.jdbc.Driver

错误信息1:

Failed to execute goal org.mybatis.generator:mybatis-generator-maven-plugin:1.3.5:generate (default-cli) on project springdatajpa: Execution default-cli of goal org.mybatis.generator:mybatis-generator-maven-plugin:1.3.5:generate failed: Exception getting JDBC Driver: com.mysql.cj.jdbc.Driver -> [Help 1]

解决方法1:

在plugin中添加mysql-connector-java的dependency,被证明是有效的.

<plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <!-- mybatis-generator自动生成代码插件 -->
            <plugin>
                <groupId>org.mybatis.generator</groupId>
                <artifactId>mybatis-generator-maven-plugin</artifactId>
                <version>1.3.5</version>
            <dependencies>
                <dependency>
                    <groupId>mysql</groupId>
                    <artifactId>mysql-connector-java</artifactId>
                    <!--<scope>runtime</scope>-->
                    <version>8.0.13</version>
                </dependency>
            </dependencies>
            </plugin>

        </plugins>

错误信息2:

Failed to execute goal org.mybatis.generator:mybatis-generator-maven-plugin:1.3.5:generate (default-cli) on project springdatajpa: 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. -> [Help 1]

解决方法2:

之前的url

connectionURL="jdbc:mysql://localhost:3306/mybatis

修改generatorConfig.xml中数据库连接url为:
注意字节在xml中写&,会因为未转义而报错要将&写成&amp;

connectionURL="jdbc:mysql://localhost:3306/mybatis?serverTimezone=UTC&amp;useUnicode=true&amp;characterEncoding=utf-8"
原文地址:https://www.cnblogs.com/DiZhang/p/12544818.html