2 quanzhaocai quanzhaocai 于 2016.02.16 14:18 提问

使用MyBatis时报错,求解?

org.apache.ibatis.exceptions.PersistenceException:

Error building SqlSession.

The error may exist in me/pacl/mapping/userMapper.xml

Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'me.gacl.domain.User'. Cause: java.lang.ClassNotFoundException: Cannot find class: me.gacl.domain.User

at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:82)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:66)
at me.pacl.test.MyBatisUtil.getSqlSessionFactory(MyBatisUtil.java:19)
at me.pacl.test.MyBatisUtil.getSqlSession(MyBatisUtil.java:41)
at me.pacl.test.TestCRUDBXmlMapper.testAdd(TestCRUDBXmlMapper.java:13)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'me.gacl.domain.User'. Cause: java.lang.ClassNotFoundException: Cannot find class: me.gacl.domain.User
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:115)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:95)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:80)
... 27 more
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'me.gacl.domain.User'. Cause: java.lang.ClassNotFoundException: Cannot find class: me.gacl.domain.User
at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:120)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:92)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.mapperElement(XMLConfigBuilder.java:340)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:113)
... 29 more
Caused by: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'me.gacl.domain.User'. Cause: java.lang.ClassNotFoundException: Cannot find class: me.gacl.domain.User
at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:118)
at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:68)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:135)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:128)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:118)
... 32 more
Caused by: org.apache.ibatis.type.TypeException: Could not resolve type alias 'me.gacl.domain.User'. Cause: java.lang.ClassNotFoundException: Cannot find class: me.gacl.domain.User
at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:120)
at org.apache.ibatis.builder.BaseBuilder.resolveAlias(BaseBuilder.java:149)
at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:116)
... 36 more
Caused by: java.lang.ClassNotFoundException: Cannot find class: me.gacl.domain.User
at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:200)
at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:89)
at org.apache.ibatis.io.Resources.classForName(Resources.java:261)
at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:116)
... 38 more

4个回答

rui888
rui888   Ds   Rxr 2016.02.16 14:18

有这个嘛 me.gacl.domain.User

quanzhaocai
quanzhaocai   2016.02.16 14:32

请问你说的是哪里?是映射文件吗?

supwuq
supwuq   2016.02.16 16:40

TypeException: Could not resolve type alias 'me.gacl.domain.User'. Cause: java.lang.ClassNotFoundException: Cannot find class: me.gacl.domain.User
类型错误,首先,确定me.gacl.domain.User 这个类是否存在,路径是否正确。如果前面还没解决 看下面:
不知道你的是输入参数的类型错误还是输出的参数错误,
建议:如果是输入参数,就一个一个设置输入参数类型:例如:values (#{code,jdbcType=VARCHAR}, #{franchiserId,jdbcType=INTEGER}, #{useFlag,jdbcType=INTEGER},
如果是输出参数:那么你查询出来的每列名字和你的类属性名字要一样,区分大小写。

select A as 类的属性名 ,B as 类的属性名 from t_table

Royal_lr
Royal_lr   Ds   Rxr 2016.02.17 11:35

配置文件写的有问题吧,,,

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
mybatis-generator自动生成报错
使用mybatis-generator自动生成是报错:Table configuration with catalog null, schema null, and table **** did not resolve to any tables 表格不存在(注意配置文件中的表名于数据库中的表名有无差别,“__”于"_")
mybatis map查询时若key值为空时,不返回结果,想要返回null时的处理http://mp.blog.csdn.net/postedit办法
springMVC+mybatis查询数据,返回resultType=”map”时,如果数据为空的字段,则该字段省略不显示,可以通过添加配置文件,规定查询数据为空是则返回null。 <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD SQL MAP Config 3.1//EN" "http://mybatis.org/dtd/mybat
SpringMVC和mybatis整合时遇见的错误
在SpringMVC和mybatis整合时遇见个问题,我整合SSM框架时候,spring+mybatis用单元测试是可以运行的,增删改查都没问题。SpringMVC也是可以运行的,WEB-INF目录下的jsp也可以用Controller显示,不同页面之间的参数传递也是没问题。 但是mybatis和SpringMVC放一块就出问题了  严重: Exception sending cont
Mybatis------ @Resource注解出现错误
解决方案: 找到这个类  在这个类上面添加@Component注解。
Mybatis 插入date类型报错解决方案
Mybatis 插入 数据库是为了防止插入空时报错, Mybatis 提供了一套机制,只要给定插入的字段的类型,如果为空,则它会自动处理为相应类型的默认值: #{ordercd,jdbcType=VARCHAR}       我们都知道,Date类型是精确到时分秒的, 如果需要精确到秒以后,则需要使用 TIMESTAMP 类型   如果数
mybatis中Dao接口里方法的参数注解以避免报错
用@Param(“形参”)写在方法里参数的前面,以避免不认识是哪个参数的问题。
MyBatis使用foreach进行批量插入遇到的问题以及解决方法
<insert id="addPartion" parameterType="java.util.List" useGeneratedKeys="false"> INSERT INTO PDA_PARTITON (BSM,CZQDM,CZQMC,USERID,USERNAME,DUTY,FLAG,SUPERCODE,SUPERNAME) SELECT SEQ_
mybatis批量添加
mybatis批量添加的时候报错总结报错 parameter'_frch_item_0 not found
Mybatis插入空值报错
今天在做单元测试插入测试数据的时候,发现有 报错。 Exception in thread "main" org.springframework.jdbc.UncategorizedSQLException: Error setting null for parameter #6 with JdbcType OTHER . Try setting a different JdbcType f
mybatis pagehelper分页查询时候报错
今天再做开发的时候遇到了mybatis Pagehelper   分页查询的错误。The error occurred while handling results ### SQL: SELECT count(*) FROM tb_pro_rating WHERE  pro_info_id = ? ### Cause: j,找了很久没有找到原因。              最后跟踪源代码,发现