首页   >   代码编程

使用mybatis-generator自动生成mapper失败

由于在项目中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失败

QQ群: 686430774  /  718410762

站长Q: 1347384268

如果文章有帮到你,可以考虑请博主喝杯咖啡!

分享到:

欢迎分享本文,转载请注明出处!

作者:不忘初心

发布时间:2019-04-20

永久地址:https://www.jiweichengzhu.com/article/e81e53e695f7488a9cd7bad15b59bbb5

评论