解决mybatis逆向工程生成代码报错

您所在的位置:网站首页 pluginexecutionexception 解决mybatis逆向工程生成代码报错

解决mybatis逆向工程生成代码报错

2023-12-25 03:15| 来源: 网络整理| 查看: 265

在用mybatis逆向工程生成代码时报错: 问题描述:

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

[INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.212 s [INFO] Finished at: 2020-11-15T09:20:09+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.mybatis.generator:mybatis-generator-maven-plugin:1.3.7:generate (default-cli) on project springboot: Execution default-cli of goal org.mybatis.generator:mybatis-generator-maven-plugin:1.3.7:generate failed: Exception getting JDBC Driver: com.mysql.cj.jdbc.Driver -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException 原因分析:

其实就是版本问题。 这种情况是pom文件的配置错了,是里面的版本问题,由于使用了mysql8.0以上的版本,因此在配置里也要改成8.0的version,而不是5.几的version 正确如下:

解决方案:

将pom文件中mybaitis-connector-core版本更换为8.0.15(只要是8以上的就可以)

org.springframework.boot spring-boot-maven-plugin org.mybatis.generator mybatis-generator-maven-plugin 1.3.7 true true mysql mysql-connector-java 8.0.15

如下截图所所示,pom文件和generatorConfig.xml示在这里插入图片描述 在这里插入图片描述

还需要注意 **generatorConfig.xml中 ** ,下的 targetProject路径要写对;我原本写的是“项目名/src/main/java/”,出现The specified target project directory springboot\src\main\resources does not exist表示生成目录没找到。正确写法应该是 把springboot这个项目名去掉 为 targetProject="src\main\java";

最后生成代码如下: 在这里插入图片描述

文章错误解决参考

链接: link.



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3