您现在的位置是:网站首页 > 代码编程 > 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-generator自动生成mapper失败

mybatisgenerator

看完文章,有任何疑问,请加入群聊一起交流!!!

很赞哦! ()

文章评论

  • 请先说点什么
    人参与,条评论

请使用电脑浏览器访问本页面,使用手机浏览器访问本页面会导致下载文件异常!!!

雨落无影

关注上方公众号,回复关键字【下载】获取下载码

用完即删,每次下载需重新获取下载码

若出现下载不了的情况,请及时联系站长进行解决

站点信息

  • 网站程序:spring + freemarker
  • 主题模板:《今夕何夕》
  • 文章统计:篇文章
  • 标签管理标签云
  • 微信公众号:扫描二维码,关注我们