`

Cannot enable lazy loading because CGLIB is not available.

 
阅读更多

整合MyBatis与Spring3.05框架时发现报如下错误:原因是因为缺少cglib包。

 

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in URL [file:/G:/SoftWare/tomcat/apache-tomcat-6.0.20/webapps/mideaAdmin/WEB-INF/classes/spring/spring-common-config.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse config resource: class pat
resource [mybatis/mybatis.xml]; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.lang.IllegalStateException: Cannot enable lazy loading because CGLIB is not available. Add CGLIB to your classpath.
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
        at org.apache.catalina.core.StandardService.start(StandardService.java:516)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: org.springframework.core.NestedIOException: Failed to parse config resource: class path resource [mybatis/mybatis.xml]; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.lang.IllegalStateException: Cannot enable lazy loading because CGLIB is not available. Add CGLIB to your classpath.
        at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:354)
        at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessionFactoryBean.java:269)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
        ... 36 more
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.lang.IllegalStateException: Cannot enable lazy loading because CGLIB is not available. Add CGLIB to your classpath.
        at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:85)
        at org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:69)
        at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:348)
       
解决方案:
原因是因为少了cglib-2.2.jar ,而cglig-2.2.jar又引用了asm-2.2.3.jar 所以这两个jar包都需要导入。

重新服务启动之后错误就消失了。

分享到:
评论

相关推荐

    asm5.0.jar

    Cause: java.lang.IllegalStateException: Cannot enable lazy loading because CGLIB is not available. Add CGLIB to your classpath.:java.lang.IncompatibleClassChangeError: class ...

    Lazy Loading:CSS懒加载策略.docx

    Lazy Loading:CSS懒加载策略.docx

    Lazy Loading:懒加载技术概论.docx

    Lazy Loading:懒加载技术概论.docx

    Lazy Loading:JavaScript懒加载实现.docx

    Lazy Loading:JavaScript懒加载实现.docx

    Lazy loading - eager loading

    In this article I want to discuss the lazy loading mechanism provided by NHibernate. It is recommended for maximum flexibility to define all relations in your domain as lazy loadable. This is the ...

    PyPI 官网下载 | lazy-budget-0.4.0.tar.gz

    《PyPI官网下载 | lazy-budget-0.4.0.tar.gz——深入理解Python库与分布式系统》 在软件开发领域,PyPI(Python Package Index)是Python开发者的重要资源库,它为全球Python开发者提供了海量的开源软件包。本文将...

    jQuery.lazyload.js

    Lazy Load 是一个用 JavaScript 编写的 jQuery 插件. 它可以延迟加载长页面中的图片. 在浏览器可视区域外的图片不会被载入, 直到用户将页面滚动到它们所在的位置. 这与图片预加载的处理方式正好是相反的. 在包含很多...

    lazy_load_tree_layui.zip

    在“lazy_load_tree_layui.zip”这个压缩包中,我们看到了一个经过自动化构建的layui源代码,其中特别添加了懒加载功能,这对于处理大数据量的树形结构数据尤为关键。本文将深入解析这个懒加载树组件的实现原理及...

    页面实现Lazy Loading效果,类似于微博

    在网页开发中,"页面实现Lazy Loading效果"是一种优化用户体验的技术策略,特别是在处理大量图片或者内容的页面时。Lazy Loading,即延迟加载或惰性加载,是指只在用户滚动到可视区域时才加载图片或其他资源,而不是...

    Lazy_Version_10.7_Final.7z.004.torrent

    Lazy_Version_10.7_Final.7z.004.torrent

    Python库 | lazy-budget-0.4.2.tar.gz

    资源分类:Python库 所属语言:Python 资源全名:lazy-budget-0.4.2.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    Python库 | lazy-budget-0.6.0.tar.gz

    《Python库lazy-budget-0.6.0深度解析》 在Python的世界里,库是开发者的重要工具,它们提供了丰富的功能,让编程变得更加高效便捷。本文将深入探讨名为“lazy-budget-0.6.0”的Python库,这个库以其独特的方式处理...

    IOS TableView Lazy Loading Demo

    当应用需要加载图片时,特别是网络图片,采用“懒加载”(Lazy Loading)策略是提高性能和节省资源的有效方式。这个“IOS TableView Lazy Loading Demo”就是演示了如何将UITableView与懒加载技术相结合,以优化用户...

    Python库 | lazy_python-0.2.1.tar.gz

    首先,让我们理解什么是“lazy loading”或“惰性加载”。这是一种编程策略,其中对象或数据只有在真正需要时才会被创建或加载。这种技术在处理大数据、节省内存和提高程序性能方面尤其有用。lazy_python库正是基于...

    Lazy Loading:懒加载与用户体验.docx

    Lazy Loading:懒加载与用户体验.docx

    Lazy Loading:视频懒加载实现方法.docx

    Lazy Loading:视频懒加载实现方法.docx

    Lazy Loading:懒加载与SEO优化.docx

    Lazy Loading:懒加载与SEO优化.docx

    Lazy Loading:懒加载与性能优化.docx

    Lazy Loading:懒加载与性能优化.docx

    jquery.lazyload.js

    jQuery.Lazyload.js的核心原理在于"懒加载"(Lazy Loading)。这种技术主要是针对网页中的图片资源,尤其是那些位于页面滚动视窗之外的图片。传统的网页加载方式会一次性加载所有图片,而懒加载则只加载当前可视区域...

    lazyloading.rar

    在移动设备上,由于网络资源有限以及用户对页面加载速度的高要求,图片懒惰加载(Lazy Loading)技术成为了一种优化网页性能的有效方法。"lazyloading.rar"这个压缩包文件提供了一个实现移动端图片懒惰加载的解决...

Global site tag (gtag.js) - Google Analytics