allergic_mango
2021-07-06 18:42
采纳率: 100%
浏览 81
已采纳

mybatis-plus 代码生成器启动报类不存在

img
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: com/baomidou/mybatisplus/generator/engine/AbstractTemplateEngine
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:650)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:632)
Caused by: java.lang.ClassNotFoundException: com.baomidou.mybatisplus.generator.engine.AbstractTemplateEngine
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 7 more

Process finished with exit code 1

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

8条回答 默认 最新

  • 404警告 2021-07-07 19:46
    已采纳

    把这个去掉

    img

    已采纳该答案
    评论
    解决 1 无用
    打赏 举报
  • allergic_mango 2021-07-06 18:43

    图片上传不了

    评论
    解决 无用
    打赏 举报
  • 404警告 2021-07-06 18:45

    导入相应依赖了吗:

     <!-- mybatis-plus -->
            <dependency>
                <groupId>com.baomidou</groupId>
                <artifactId>mybatis-plus-boot-starter</artifactId>
                <version>3.4.1</version>
            </dependency>
    
    
    评论
    解决 无用
    打赏 举报
  • allergic_mango 2021-07-06 18:49
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <parent>
            <artifactId>xxxxx-boot-parent</artifactId>
            <groupId>org.xxxxxx.boot</groupId>
            <version>2.4.2</version>
        </parent>
        <modelVersion>4.0.0</modelVersion>
    
        <artifactId>xxxxx-microservice-form</artifactId>
    
        <dependencies>
    
            <!-- 引入微服务启动依赖 starter -->
            <dependency>
                <groupId>org.xxxxxx.boot</groupId>
                <artifactId>jeecg-boot-starter-cloud</artifactId>
                <exclusions>
                    <exclusion>
                        <groupId>com.alibaba.cloud</groupId>
                        <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.xxxxx.boot</groupId>
                <artifactId>jeecg-boot-base-core</artifactId>
                <exclusions>
                    <exclusion>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-quartz</artifactId>
                    </exclusion>
    
                    <exclusion>
                        <groupId>org.xxxxxx.boot</groupId>
                        <artifactId>hibernate-re</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>com.microsoft.sqlserver</groupId>
                        <artifactId>sqljdbc4</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>com.oracle</groupId>
                        <artifactId>ojdbc6</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.postgresql</groupId>
                        <artifactId>postgresql</artifactId>
                    </exclusion>
    
                    <exclusion>
                        <groupId>com.aliyun</groupId>
                        <artifactId>aliyun-java-sdk-dysmsapi</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>com.aliyun.oss</groupId>
                        <artifactId>aliyun-sdk-oss</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>com.xkcoding.justauth</groupId>
                        <artifactId>justauth-spring-boot-starter</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>io.minio</groupId>
                        <artifactId>minio</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-data-redis</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
    
            <dependency>
                <groupId>com.baomidou</groupId>
                <artifactId>mybatis-plus-generator</artifactId>
                <version>3.4.1</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.freemarker</groupId>
                <artifactId>freemarker</artifactId>
            </dependency>
            <dependency>
                <groupId>commons-lang</groupId>
                <artifactId>commons-lang</artifactId>
                <version>2.6</version>
            </dependency>
            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpclient</artifactId>
                <version>4.5.5</version>
            </dependency>
    
            <dependency>
                <groupId>org.freemarker</groupId>
                <artifactId>freemarker</artifactId>
                <version>2.3.30</version>
            </dependency>
    
    
            <dependency>
                <groupId>cn.smallbun.screw</groupId>
                <artifactId>screw-core</artifactId>
                <version>1.0.5</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-test</artifactId>
            </dependency>
    
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>3.8.1</version>
            </dependency>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
            </dependency>
    
            <!-- HikariCP -->
            <dependency>
                <groupId>com.zaxxer</groupId>
                <artifactId>HikariCP</artifactId>
                <version>3.4.5</version>
            </dependency>
            <dependency>
                <groupId>com.xuxueli</groupId>
                <artifactId>xxl-job-core</artifactId>
                <version>2.2.0</version>
            </dependency>
    
            <dependency>
                <groupId>com.netflix.feign</groupId>
                <artifactId>feign-httpclient</artifactId>
                <version>8.17.0</version>
            </dependency>
    
    
        </dependencies>
    
        <build>
            <finalName>${project.artifactId}</finalName>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
    
            </plugins>
        </build>
    
    </project>
    
    
    

    部分隐去,我用xxxx代替了,如果要依赖树我再发

    评论
    解决 无用
    打赏 举报
  • allergic_mango 2021-07-06 19:24
    /**
     * 
     */
    
    
    import com.baomidou.mybatisplus.annotation.DbType;
    import com.baomidou.mybatisplus.annotation.IdType;
    import com.baomidou.mybatisplus.generator.AutoGenerator;
    import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
    import com.baomidou.mybatisplus.generator.config.GlobalConfig;
    import com.baomidou.mybatisplus.generator.config.PackageConfig;
    import com.baomidou.mybatisplus.generator.config.StrategyConfig;
    import com.baomidou.mybatisplus.generator.config.rules.DateType;
    import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
    import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
    
    /**
     * @author 
     *
     */
    public class CodeGenerator {
        
         private static String DataBaseName = "xxxx";
            private static String Url = "xxx";
            private static String DriverName = "com.mysql.cj.jdbc.Driver";
            private static String Username = "xxx";
            private static String Password = "xxx";
            private static String projectPath = System.getProperty("user.dir");
            
            public static void main(String[] args) {
                // 1、代码生成器
                AutoGenerator mpg = new AutoGenerator();
    
                // 2、全局配置
                GlobalConfig gc = new GlobalConfig()
                        .setAuthor("xxxx")
                        .setDateType(DateType.ONLY_DATE)            //定义生成的实体类中日期类型
                        .setFileOverride(false)                     //重新生成时文件是否覆盖
                        .setIdType(IdType.ID_WORKER)            //主键策略
                        .setOpen(false)
                        .setOutputDir(projectPath+"/src/main/java") //输出路径
                        .setServiceName("%sService")                //去掉Service接口的首字母I
                        .setSwagger2(true)                          //开启Swagger2模式
                        .setActiveRecord(false)
                        .setControllerName(null);
                mpg.setGlobalConfig(gc);
    
                // 3、数据源配置
                DataSourceConfig dsc = new DataSourceConfig()
    //                    .setDbQuery()               // 数据库信息查询类
    //                    .setSchemaName()
    //                    .setTypeConvert()
                        .setDbType(DbType.MYSQL)
                        .setDriverName(DriverName)
                        .setPassword(Password)
                        .setUrl(Url)
                        .setUsername(Username);
                mpg.setDataSource(dsc);
    
                // 4、包配置
                PackageConfig pc = new PackageConfig()
                        .setParent("xxxxx")
                        .setController("controller")
                        .setEntity("bean")
                        .setMapper("mapper")
                        .setService("service")
                        .setModuleName("")
    //                    .setPathInfo()              // 路径配置信息
                        .setServiceImpl("service.impl")
                        .setXml("mapper.xml");
                mpg.setPackageInfo(pc);
    
                // 5、策略配置
                StrategyConfig strategy = new StrategyConfig()
                        .setControllerMappingHyphenStyle(true)                  //url中驼峰转连字符
                        .setColumnNaming(NamingStrategy.underline_to_camel)     //数据库表映射到实体的命名策略
                        .setNaming(NamingStrategy.underline_to_camel)
                        .setEntityLombokModel(true)
                        .setRestControllerStyle(true)                           //restful api风格控制器
                        .setTablePrefix("tb_newbee_")                            //生成实体时去掉表前缀
    //                    .setSuperControllerClass()                              //公共父类 , 你自己的父类控制器,没有就不用设置!
    //                    .setSuperEntityClass()                                  //自定义继承的Entity类全称,带包名
    //                    .setSuperEntityColumns()                                //写于父类中的公共字段
                        .setInclude(
                                "additive_update_record"
                        );
                mpg.setStrategy(strategy);
    
                // 6、添加模板引擎
                mpg.setTemplateEngine(new FreemarkerTemplateEngine());          // 添加 模板引擎
    
                // 7、执行
                mpg.execute();
            }
    
    }
    
    
    评论
    解决 无用
    打赏 举报
  • allergic_mango 2021-07-06 20:31
    <dependency>
                <groupId>com.baomidou</groupId>
                <artifactId>mybatis-plus-boot-starter</artifactId>
                <version>3.4.1</version>
            </dependency>
            <dependency>
                <groupId>org.apache.velocity</groupId>
                <artifactId>velocity-engine-core</artifactId>
                <version>2.3</version>
            </dependency>
            <dependency>
                <groupId>com.ibeetl</groupId>
                <artifactId>beetl</artifactId>
                <version>2.8.1</version>
            </dependency>
    
            <dependency>
                <groupId>org.freemarker</groupId>
                <artifactId>freemarker</artifactId>
            </dependency>
    
    评论
    解决 无用
    打赏 举报
  • oNuoyi 2021-07-07 10:08

    右边的maven,先clean在install一下重新启动

    评论
    解决 无用
    打赏 举报
  • li.siyuan 2021-07-07 16:10

    处理好了没 要不要远程给你处理?

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题