您现在的位置是:网站首页 > 代码编程 > JAVA开发JAVA开发
【原】使用mybatis-generator自动生成mapper失败
不忘初心 2019-04-20 围观() 评论() 点赞() 【JAVA开发】
简介:在使用mybatis-generator插件自动生成mapper文件的时候,提示“No plugin found for prefix 'mybatis-generator' in the current project”,因为在pom.xml文件中少了一段plugin配置。
由于在项目中mybatis和jpa的混用,导致大家都很少关注mapper.xml文件的字段了,上周线上出了一个问题,就是因为使用jpa顺手了,增加了字段,下意识的以为会自动处理,所以就没有手动在mapper中增加字段。
今天把最新的字段都整理一遍到mapper中去,表很大,字段太多了,准备使用mybatis插件进行自动生成,然后我拷贝一下,但是在使用mybatis-generator插件自动生成mapper文件的时候,却失败了:
[ERROR] No plugin found for prefix 'mybatis-generator' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Library/Apache/maven-3.5.3/repository), central (https://repo.maven.apache.org/maven2)] -> [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/NoPluginFoundForPrefixException
felixdeMacBook-Pro:pasarpinjam-server felix$ mvn mybatis-generator:generate
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.huijie.xlab.lp.market:pasarpinjam-server:war:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.github.penggle:kaptcha:jar -> duplicate declaration of version 2.3.2 @ line 208, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[WARNING] The project com.huijie.xlab.lp.market:pasarpinjam-server:war:0.0.1-SNAPSHOT uses prerequisites which is only intended for maven-plugin projects but not for non maven-plugin projects. For such purposes you should use the maven-enforcer-plugin. See https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html
[WARNING] The POM for org.eclipse.m2e:lifecycle-mapping:jar:1.0.0 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.eclipse.m2e:lifecycle-mapping:1.0.0: Plugin org.eclipse.m2e:lifecycle-mapping:1.0.0 or one of its dependencies could not be resolved: Failure to find org.eclipse.m2e:lifecycle-mapping:jar:1.0.0 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml (14 kB at 8.2 kB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml (20 kB at 12 kB/s)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.973 s
[INFO] Finished at: 2019-04-15T11:22:20+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'mybatis-generator' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Library/Apache/maven-3.5.3/repository), central (https://repo.maven.apache.org/maven2)] -> [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/NoPluginFoundForPrefixException
开始还懵逼了一下,看提示信息是仓库中没有找到插件,转念一想不太可能,因为这不是第一次在本机使用这个插件了,之前在别的项目中也使用过,去之前的项目配置中比对了一下,发现在pom.xml文件中少了一段配置:
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<configuration>
<configurationFile>${basedir}/src/main/resources/mybatis/generatorConfig.xml</configurationFile>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
</plugin>
加上之后,再次执行:mvn mybatis-generator:generate,问题得到解决!
看完文章,有任何疑问,请加入群聊一起交流!!!
很赞哦! ()
相关文章
- mybatis中foreach的变量名和if的变量名相同
- springmvc + spring + mybatis整合搭建图文教程
- mybatis-generator代码自动生成插件的使用图文教程
- Mybatis调用MySQL存储过程图文教程
- IntelliJ IDEA去掉mybatis映射mapper文件的背景色
- mybatis的if判断条件将字符串解析成了数字
- SSM框架基础整合搭建图文教程
- mybatis整合ehcache配置二级缓存
- springboot项目提示“Failed to determine a suitable driver class”
- ehcache警告“diskStorePath is already used by an existing CacheManager”
标签云
猜你喜欢
- IntelliJ IDEA 2019.2已经可以利用补丁永久破解激活了
- IntelliJ IDEA 2019.3利用补丁永久破解激活教程
- IntelliJ IDEA高版本最灵活的永久破解激活方法(含插件激活,时长你说了算)
- Jetbrains全家桶基于ja-netfilter的最新破解激活详细图文教程
- IntelliJ IDEA 2022.1永久破解激活教程(亲测可用,持续更新)
- 分享几个正版 IntelliJ IDEA 激活码(破解码、注册码),亲测可用,持续更新
- ja-netfilter到底需不需要mymap,2021.3.2版本激活失效?
- 如何激活idea2022.1及以上版本中的插件(亲测可用)
- 【史上最全】IntelliJ IDEA最新2022.1版本安装和激活视频教学(含插件)
- IntelliJ IDEA 2022.2 版本最新2099年永久激活方法,亲测可用,也可以开启新UI了。
站点信息
- 网站程序:spring + freemarker
- 主题模板:《今夕何夕》
- 文章统计:篇文章
- 标签管理:标签云
- 微信公众号:扫描二维码,关注我们