mybatis-plus报错内存溢出

版本 3.4.1

报错信息

java 复制代码
Caused by: org.apache.ibatis.builder.BuilderException: Error evaluating expression 'ew.sqlSegment != null and ew.sqlSegment != '' and ew.nonEmptyOfWhere'. Cause: org.apache.ibatis.ognl.OgnlException: sqlSegment [java.lang.OutOfMemoryError: Java heap space]
	at org.apache.ibatis.scripting.xmltags.OgnlCache.getValue(OgnlCache.java:48)
	at org.apache.ibatis.scripting.xmltags.ExpressionEvaluator.evaluateBoolean(ExpressionEvaluator.java:32)
	at org.apache.ibatis.scripting.xmltags.IfSqlNode.apply(IfSqlNode.java:34)
	at org.apache.ibatis.scripting.xmltags.MixedSqlNode.lambda$apply$0(MixedSqlNode.java:32)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
	at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:32)
	at org.apache.ibatis.scripting.xmltags.TrimSqlNode.apply(TrimSqlNode.java:55)
	at org.apache.ibatis.scripting.xmltags.MixedSqlNode.lambda$apply$0(MixedSqlNode.java:32)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
	at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:32)
	at org.apache.ibatis.scripting.xmltags.IfSqlNode.apply(IfSqlNode.java:35)
	at org.apache.ibatis.scripting.xmltags.MixedSqlNode.lambda$apply$0(MixedSqlNode.java:32)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
	at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:32)
	at org.apache.ibatis.scripting.xmltags.DynamicSqlSource.getBoundSql(DynamicSqlSource.java:39)
	at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:305)
	at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:53)
	at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61)
	at com.sun.proxy.$Proxy316.query(Unknown Source)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
	at jdk.internal.reflect.GeneratedMethodAccessor410.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426)
	... 76 common frames omitted

更换版本

XML 复制代码
    <!-- 代码生成 -->
            <dependency>
                <groupId>com.baomidou</groupId>
                <artifactId>mybatis-plus-generator</artifactId>
                <version>3.5.0</version>
            </dependency>

            <!-- Mybatis-Plus 依赖配置 -->
            <!-- https://mvnrepository.com/artifact/com.baomidou/mybatis-plus-boot-starter -->
            <dependency>
                <groupId>com.baomidou</groupId>
                <artifactId>mybatis-plus-boot-starter</artifactId>
                <version>3.5.0</version>
            </dependency>

代码生成工具类

java 复制代码
package com.pojo.common.core.utils;

/**
 * Author:ZhuShangJin
 * Date:2018/6/12
 */


import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.config.*;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.pojo.common.core.web.controller.BaseController;
import com.pojo.common.core.web.domain.BaseEntity;
import com.pojo.common.core.web.service.BaseService;
import com.pojo.common.core.web.service.impl.BaseServiceImpl;

/**
 * <p>
 * 代码生成器演示
 * </p>
 */

public class MyBatisPlusGenerateUtil {

    /**
     * 数据源配置
     */
    private static final DataSourceConfig DATA_SOURCE_CONFIG = new DataSourceConfig
            .Builder("jdbc:mysql://xxx.xx.xx.xx:19306/yhpt?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8",
            "root", "xxxxxx")
            .build();

    /**
     * <p>
     * MySQL 生成演示
     * </p>
     */
    public static void main(String[] args) {

        AutoGenerator generator = new AutoGenerator(DATA_SOURCE_CONFIG);
        generator.strategy(strategyConfig());
        generator.global(globalConfig());
        generator.packageInfo(packageConfig());
        generator.template(templateConfig());
        generator.execute();
    }


    /**
     * 策略配置
     */
    protected static StrategyConfig strategyConfig() {


        return new StrategyConfig.Builder().addTablePrefix(new String[]{"prj_"})
                .addInclude(new String[]{"prj_device_oper_history"}).entityBuilder()
                .superClass(BaseEntity.class)
                .enableChainModel()
                .enableLombok()
                .enableRemoveIsPrefix()
                .enableTableFieldAnnotation()
                .enableActiveRecord()
                .naming(NamingStrategy.underline_to_camel)
                .columnNaming(NamingStrategy.underline_to_camel)
                .addSuperEntityColumns("id", "create_by", "create_time", "update_by", "update_time")
                .idType(IdType.AUTO)
                .controllerBuilder()
                .superClass(BaseController.class)
                .enableHyphenStyle()
                .enableRestStyle()
                .serviceBuilder()
                .superServiceClass(BaseService.class)
                .superServiceImplClass(BaseServiceImpl.class)
                .formatServiceFileName("%sService")
                .formatServiceImplFileName("%sServiceImp")
                .mapperBuilder()
                .superClass(BaseMapper.class)
                .enableBaseResultMap()
                .enableBaseColumnList()
                .formatMapperFileName("%sMapper")
                .formatXmlFileName("%sXml")
                .build();
    }

    /**
     * 全局配置 作者 输出目录
     */
    protected static GlobalConfig globalConfig() {
        return new GlobalConfig.Builder().author("zsj").fileOverride().outputDir("d://test").build();
    }

    /**
     * 包配置 代码包名
     */
    protected static PackageConfig packageConfig() {
        return new PackageConfig.Builder().parent("com.pojo.prj")
//                .moduleName("device")
                .mapper("mapper")
                .xml("mapper.xml")
                .entity("domain")
                .build();
    }

    /**
     * 模板配置
     */
    protected static TemplateConfig templateConfig() {
        return new TemplateConfig.Builder().entity("entity.java")
                .build();
    }

    /**
     * 注入配置
     */
    protected static InjectionConfig.Builder injectionConfig() {
        // 测试自定义输出文件之前注入操作,该操作再执行生成代码前 debug 查看
        return new InjectionConfig.Builder().beforeOutputFile((tableInfo, objectMap) -> {
            System.out.println("tableInfo: " + tableInfo.getEntityName() + " objectMap: " + objectMap.size());
        });
    }

}
相关推荐
鹿屿二向箔39 分钟前
基于SSM(Spring + Spring MVC + MyBatis)框架的咖啡馆管理系统
spring·mvc·mybatis
aloha_78910 小时前
从零记录搭建一个干净的mybatis环境
java·笔记·spring·spring cloud·maven·mybatis·springboot
毕业设计制作和分享11 小时前
ssm《数据库系统原理》课程平台的设计与实现+vue
前端·数据库·vue.js·oracle·mybatis
paopaokaka_luck14 小时前
基于Spring Boot+Vue的助农销售平台(协同过滤算法、限流算法、支付宝沙盒支付、实时聊天、图形化分析)
java·spring boot·小程序·毕业设计·mybatis·1024程序员节
cooldream200915 小时前
Spring Boot中集成MyBatis操作数据库详细教程
java·数据库·spring boot·mybatis
不像程序员的程序媛16 小时前
mybatisgenerator生成mapper时报错
maven·mybatis
小布布的不19 小时前
MyBatis 返回 Map 或 List<Map>时,时间类型数据,默认为LocalDateTime,响应给前端默认含有‘T‘字符
前端·mybatis·springboot
背水21 小时前
Mybatis基于注解的关系查询
mybatis
free_girl_fang21 小时前
高效作业之Mybatis缓存
java·ide·缓存·mybatis
十二同学啊1 天前
Mybatis拦截器中获取@RequestBody表单的值修改查询SQL
数据库·sql·mybatis