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
展开
 我来答
匿名用户
2017-02-20
展开全部
在User.xml配置文件中,select属性的resultType——指定输出结果的Java类型(指定单条结果的java类型)的路径出错了。另一个原因在 select后 是resultMap,却写成了resultType。
wwwzhangsan
2014-04-17 · TA获得超过286个赞
知道小有建树答主
回答量:119
采纳率:0%
帮助的人:115万
展开全部
你的UserMapper是不是定义成类了?应该定义为接口。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
calm339
2014-04-09 · TA获得超过214个赞
知道答主
回答量:193
采纳率:100%
帮助的人:96.7万
展开全部
MyBatisUtil 这个类怎么写的
追问

已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 2条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式