Mybatis中的错误org.apache.ibatis.exceptions.PersistenceException
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mybatis中的错误org.apache.ibatis.exceptions.PersistenceException相关的知识,希望对你有一定的参考价值。
本人菜鸟刚学用Mybatis写简单的Demo,遇到这个问题很困惑请大神指教
log4j:WARN No appenders could be found for logger (org.apache.ibatis.logging.LogFactory).log4j:WARN Please initialize the log4j system properly.Exception in thread "main" java.lang.ExceptionInInitializerError at com.main.service.UserService.<clinit>(UserService.java:13) at com.main.service.Test.main(Test.java:9)Caused by: org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession.### The error may exist in SQL Mapper Configuration### Cause: 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.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23) at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:51) at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:35) at com.main.service.MybatisUtil.<clinit>(MybatisUtil.java:23) ... 2 moreCaused 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:105) at org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:88) at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:49) ... 4 moreCaused by: java.lang.IllegalStateException: Cannot enable lazy loading because CGLIB is not available. Add CGLIB to your classpath. at org.apache.ibatis.session.Configuration.setLazyLoadingEnabled(Configuration.java:211) at org.apache.ibatis.builder.xml.XMLConfigBuilder.settingsElement(XMLConfigBuilder.java:197) at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:99) ... 6 moreCaused by: java.lang.ClassNotFoundException: Cannot find class: net.sf.cglib.proxy.Enhancer at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:188) at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:87) at org.apache.ibatis.io.Resources.classForName(Resources.java:250) at org.apache.ibatis.session.Configuration.setLazyLoadingEnabled(Configuration.java:209) ... 8 more
以上是关于Mybatis中的错误org.apache.ibatis.exceptions.PersistenceException的主要内容,如果未能解决你的问题,请参考以下文章
mybatis绑定错误-- Invalid bound statement (not found)
记录一个mybatis编写xml遇到的错误:java.lang.unsupportedOperationException