machengchengs / machengchengs.github.io

spring笔记 更好的理解springboot、maven
0 stars 0 forks source link

idea 中执行 maven 插件mybatis-generator , failed: Exception getting JDBC Driver: com.mysql.jdbc.Driver 解决方案 #3

Open machengchengs opened 3 weeks ago

machengchengs commented 3 weeks ago

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

machengchengs commented 3 weeks ago

问题原因: MyBatis Generator 仍然无法找到 MySQL 的 JDBC 驱动类 com.mysql.cj.jdbc.Driver 解决办法:

 <build>
     ......
       <plugin>
                <groupId>org.mybatis.generator</groupId>
                <artifactId>mybatis-generator-maven-plugin</artifactId>
                <version>1.3.2</version>
                <configuration>
                    <!-- 指定生成器配置文件路径 -->
                    <configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
                    <overwrite>true</overwrite>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>${mysql.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
</build>