前言:今天遇到了这个问题,刚开始觉得很容易解决的,毕竟能定位到出问题的文件和对应的字段,根据以往的经验也可以判断出是字段映射类型不匹配的问题,后来找了半天还是没找到问题的根源,从网上百度,也没看到令人满意的分析以及和我情况类似的描述。于是,下定决心,先深呼吸,然后冷静下来好好玩一下。

如下是我的分析过程,这里以提供分析的思路为主,希望以后在遇到类似的问题能一下子定位到,解决掉。

1:异常信息的一部分,如下所示,和以往一样,先仔细瞧瞧,根据异常的提示基本能定位到问题出在那个文件,那个字段或者某个小氛围,如下所示

Caused by: org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\workspace\XXX\target\ape-web-0.0.1-SNAPSHOT\WEB-INF\classes\mappers\SortCenterRouteMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalStateException: No typehandler found for mapping movementName
at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:466)
at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessionFactoryBean.java:340)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1479)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1419)
... 80 more
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalStateException: No typehandler found for mapping movementName
at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:117)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:89)
at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:464)
... 83 more
Caused by: java.lang.IllegalStateException: No typehandler found for mapping movementName
at org.apache.ibatis.mapping.ResultMapping$Builder.validate(ResultMapping.java:147)
at org.apache.ibatis.mapping.ResultMapping$Builder.build(ResultMapping.java:136)
at org.apache.ibatis.builder.MapperBuilderAssistant.assembleResultMapping(MapperBuilderAssistant.java:426)
at org.apache.ibatis.builder.MapperBuilderAssistant.buildResultMapping(MapperBuilderAssistant.java:222)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildResultMappingFromContext(XMLMapperBuilder.java:371)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:276)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:248)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElements(XMLMapperBuilder.java:240)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:113)
... 85 more

2:下面是我的分析过程

2-1:定位到出问题的文件,字段,然后对照,映射的情况,映射对象的情况,数据库表字段的情况,如下所示:

2-2:原本以为经过上面的分析一定能定位到问题的,结果让我大惑不解,没问题呀!仔仔细细看了几遍没发现有问题

2-3:后来就按照我原来分析问题的思路,再重新分析一遍(有时候我们认为不可能出现问题的地方,可能是,一旦出现问题就容易令我们崩溃的地方),下面是我重新分析的思路,根据报错的提示信息——“No typehandler found for mapping”以及异常发生的嵌套位置,试着去定位到对应的源码,然后通过调试模式看看到底是什么引起了程序抛错,比较幸运,我一下子就定位到了的可能出现问题的源码之处了,如下所示:

2-4:启动服务器,进入调试模式,跟踪源码报错的部分,分析当时的运行情况,我们看到了程序为什么抛出异常,以及可能存在问题的地方,到这里基本就定位到问题的根源了,放慢速度,让灵魂跟上脚步。让我奇怪的是我的字段明明是String类型的为什么和自己认为不一样哪?再回头看看那个String类型的真面目吧!

2-5:我去,还真不是自己认为的java.lang.String类型的?问题是定位到了,怎么解决就不说了!但是为什么是这个类型呢?是谁修改的?还是自己一不小心导致的?编程是个细致的活,所以还是要胆大心细一些吧!

3:参考

http://stackoverflow.com/questions/19273783/no-typehandler-exception-in-mybatis

java.lang.IllegalStateException: No typehandler found for mapping XXX的更多相关文章

  1. Caused by: java.lang.IllegalStateException: Ambiguous mapping found

    Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map ‘myCockpitMgrControl ...

  2. java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'waterQuality

    如果一个项目中有两个@RequestMapping("/xxx")完全相同就会报  java.lang.IllegalStateException 改进办法:修改@RequestM ...

  3. Tomcat部署项目时出错java.lang.IllegalStateException: ContainerBase.addChild: start:org.apache.catalina.Life

    Tomcat部署项目时出错java.lang.IllegalStateException: ContainerBase.addChild: start:org.apache.catalina.Life ...

  4. myeclipse 无法启动 java.lang.IllegalStateException: Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini).

    把myeclipse10 按照目录完整拷贝到了另外一台电脑, 另外的目录 原安装目录 D\:\soft\i\myeclipse10 新安装目录 E\:\soft\myeclipse10 双击启动失败, ...

  5. java.lang.IllegalStateException:Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxx...}: java.lang.IllegalSta ...

  6. java.lang.IllegalStateException: Not allowed to create transaction on shared EntityManager - use Spring transactions or EJB CMT instead

    java.lang.IllegalStateException: Not allowed to create transaction on sharedEntityManager - use Spri ...

  7. java.lang.IllegalStateException: getOutputStream() has already been called for this response

    ERROR [Engine] StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exceptionjava.lang ...

  8. 用java实现文件下载,提示java.lang.IllegalStateException: getOutputStream() has already been called for this response

    1. 用java实现文件下载,提示java.lang.IllegalStateException: getOutputStream() has already been called for this ...

  9. eclipse启动报错java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' befo

    报错: java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invo ...

随机推荐

  1. windows 环境变量

    1.考虑下面的需求,进入cmd之后,我就想执行mysql客户端命令,而这需要转到mysql安装目录,找到mysql可执行文件,在这个目录下执行mysql命令.这样太麻烦,有没有好的解决办法? 2.使用 ...

  2. WPF按钮删除默认的鼠标悬停效果

    <Style x:Key="NormalMouseButton" TargetType="Button"> <Setter Property= ...

  3. jQuery动画animate方法使用介绍

    用于创建自定义动画的函数. 返回值:jQuery animate(params, [duration], [easing], [callback]) 如果使用的是“hide”.“show”或“togg ...

  4. [转]mysql组合索引与字段顺序

    下列转自:http://www.tech-q.cn/archiver/tid-11673.html 很多时候,我们在mysql中创建了索引,但是某些查询还是很慢,根本就没有使用到索引!一般来说,可能是 ...

  5. MongoDB副本集配置系列六:定位MongoDB慢的原因

    1:想知道哪些操作拖慢了MongoDB的速度,首先需要检查当前正在执行哪些操作. gechongrepl:PRIMARY> db.currentOp() "opid" : 7 ...

  6. Spring学习笔记二:注入方式

    转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/6774608.html  我们说,IOC的实现方式是依赖注入,也就是把被依赖对象赋值到依赖对象的成员属性.怎么做 ...

  7. 【HTML5 Canvas】计算元件/显示对象经过Matrix变换后在上级/舞台上的bounds(边界矩形rect)

    如上图所示,这样的一个简单矩形,边界矩形是(x:-28, y:-35, width:152, height:128),这是在这个元件/显示对象自己的坐标空间的范围. 那么把这个放到父元件(舞台)中,再 ...

  8. gitlab webhook报500

    使用root登陆gitlab,进入如下位置:

  9. Fix problems that block programs from being installed or removed

    Follow these steps to automatically repair issues including corrupted registry keys that block you f ...

  10. redhat7.0安装ifconfig

    问题描述: Setup is unable to find the "ifconfig" program on your machine. Please make sure it ...