Mybatis中的错误org.apache.ibatis.exceptions.PersistenceException
本人菜鸟刚学用Mybatis写简单的Demo,遇到这个问题很困惑请大神指教log4j:WARNNoappenderscouldbefoundforlogger(org.a...
本人菜鸟刚学用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 展开
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 展开
2017-02-20
展开全部
在User.xml配置文件中,select属性的resultType——指定输出结果的Java类型(指定单条结果的java类型)的路径出错了。另一个原因在 select后 是resultMap,却写成了resultType。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询