• mybatis延迟加载


    配置完成后可能会报错Cannot enable lazy loading because CGLIB is not available. Add CGLIB to your classpath

    是由于缺少jar包   cglig-2.2.jar  asm-2.2.3.jar

    配置过程

    mybatis-config.xml

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
    "http://mybatis.org/dtd/mybatis-3-config.dtd">
    <configuration>
    <settings>

    <!-- 懒加载配置lazyLoadingEnabled:true使用延迟加载,false禁用延迟加载。默认为true
    aggressiveLazyLoading:true启用时,当延迟加载开启时访问对象中一个懒对象属性时,将完全加载这个对象的所有懒对象属性-->


    <setting name="lazyLoadingEnabled" value="true"/>
    <setting name="aggressiveLazyLoading" value="false"/>
    </settings>
    </configuration>

    spring-mybatis.xml

    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <!-- 自动扫描mapping.xml文件 -->
    <property name="mapperLocations" value="classpath:com/jbt/mapper/*.xml"></property>
    <property name="configLocation" value="classpath:mybatis-config.xml" />
    </bean>

    配置完成

  • 相关阅读:
    php 匿名函数和闭包
    项目在线压缩js
    USACOTrainning.The Clocks
    USACOTrainning.Mother's Milk
    c# TXT文件读写
    Access以及少量Regex
    USACOTraining.Packing Rectangles
    First
    CUGBLinker and EXE
    异常处理总结
  • 原文地址:https://www.cnblogs.com/huhuixin/p/5692173.html
Copyright © 2020-2023  润新知