编程那点事编程那点事

专注编程入门及提高
探究程序员职业规划之道!

SpringBoot通用mapper生成代码报错:java.lang.ClassNotFoundException: org.mybatis.generator.api.dom.xml.Element

SpringBoot+Mybatis开发,用到了通用mapper,生成代码的时候报错:java.lang.ClassNotFoundException: org.mybatis.generator.api.dom.xml.Element

具体如下:

Caused by: java.lang.NoClassDefFoundError: org/mybatis/generator/api/dom/xml/Element
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:348)
        at org.mybatis.generator.internal.ObjectFactory.internalClassForName(ObjectFactory.java:144)
        at org.mybatis.generator.internal.ObjectFactory.createInternalObject(ObjectFactory.java:180)
        at org.mybatis.generator.internal.ObjectFactory.createCommentGenerator(ObjectFactory.java:241)
        at org.mybatis.generator.config.Context.getCommentGenerator(Context.java:266)
        at org.mybatis.generator.codegen.mybatis3.model.SimpleModelGenerator.getCompilationUnits(SimpleModelGenerator.java:51)
        at org.mybatis.generator.codegen.mybatis3.IntrospectedTableMyBatis3Impl.getGeneratedJavaFiles(IntrospectedTableMyBatis3Impl.java:181)
        at org.mybatis.generator.config.Context.generateFiles(Context.java:460)
        at org.mybatis.generator.api.MyBatisGenerator.generate(MyBatisGenerator.java:262)
        at org.mybatis.generator.api.MyBatisGenerator.generate(MyBatisGenerator.java:182)
        at org.mybatis.generator.maven.MyBatisGeneratorMojo.execute(MyBatisGeneratorMojo.java:229)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
        ... 21 more
Caused by: java.lang.ClassNotFoundException: org.mybatis.generator.api.dom.xml.Element
        at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
        ... 34 more

网上查了下是说mybatis-generator-maven-plugin版本太高了,我看了下是1.4,我换成1.3.7就可以了。

<plugin>
    <groupId>org.mybatis.generator</groupId>
    <artifactId>mybatis-generator-maven-plugin</artifactId>
    <version>1.3.7</version>
    <configuration>
        <verbose>true</verbose>
        <overwrite>true</overwrite>
        <configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.32</version>
        </dependency>
        <dependency>
            <groupId>tk.mybatis</groupId>
            <artifactId>mapper</artifactId>
            <version>4.1.5</version>
        </dependency>
    </dependencies>
</plugin>


未经允许不得转载: 技术文章 » Java编程 » SpringBoot通用mapper生成代码报错:java.lang.ClassNotFoundException: org.mybatis.generator.api.dom.xml.Element

专注编程入门及提高,探究程序员职业规划之道!