美文网首页
Cause: org.apache.ibatis.type.Ty

Cause: org.apache.ibatis.type.Ty

作者: 秋元_92a3 | 来源:发表于2020-02-21 21:19 被阅读0次

    SpringBoot项目启服务的时候报错,详细堆栈如下:

    Caused by: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'VARCHAR'.  Cause: java.lang.ClassNotFoundException: Cannot find class: VARCHAR
        at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:118) ~[mybatis-3.4.4.jar:3.4.4]
        at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildResultMappingFromContext(XMLMapperBuilder.java:379) ~[mybatis-3.4.4.jar:3.4.4]
        at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:280) ~[mybatis-3.4.4.jar:3.4.4]
        at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:252) ~[mybatis-3.4.4.jar:3.4.4]
        at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElements(XMLMapperBuilder.java:244) ~[mybatis-3.4.4.jar:3.4.4]
        at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:116) ~[mybatis-3.4.4.jar:3.4.4]
        at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:92) ~[mybatis-3.4.4.jar:3.4.4]
        at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:521) ~[mybatis-spring-1.3.1.jar:1.3.1]
        at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessionFactoryBean.java:380) ~[mybatis-spring-1.3.1.jar:1.3.1]
        at org.mybatis.spring.SqlSessionFactoryBean.getObject(SqlSessionFactoryBean.java:547) ~[mybatis-spring-1.3.1.jar:1.3.1]
        at org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration.sqlSessionFactory(MybatisAutoConfiguration.java:153) ~[mybatis-spring-boot-autoconfigure-1.3.0.jar:1.3.0]
        at org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration$$EnhancerBySpringCGLIB$$5c96f165.CGLIB$sqlSessionFactory$0(<generated>) ~[mybatis-spring-boot-autoconfigure-1.3.0.jar:1.3.0]
        at org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration$$EnhancerBySpringCGLIB$$5c96f165$$FastClassBySpringCGLIB$$29feb7a3.invoke(<generated>) ~[mybatis-spring-boot-autoconfigure-1.3.0.jar:1.3.0]
    
    

    通过堆栈信息知道,mybatis的XML 文件中解析resultMapElement元素报错,mybatis文件的resultMap元素的代码如下:

      <resultMap id="EquipmentUpgradeQueueMap" type="EquipmentUpgradeQueue">
        <result column="id" property="id" jdbcType="DECIMAL"/>
        <result column="equipment_id" property="equipmentId" jdbcType="VARCHAR"/>
        <result column="url" property="url" jdbcType="VARCHAR"/>
        <result column="mode" property="mode" jdbcType="VARCHAR"/>
        <result column="run_status" property="runStatus" jdbcType="DECIMAL"/>
        <result column="remark" property="remark" jdbcType="VARCHAR"/>
        <result column="operator" property="operator" jdbcType="DECIMAL"/>
        <result column="time_out" property="timeOut" jdbcType="DECIMAL"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
        <result column="update_user" property="updateUser" javaType="VARCHAR"/>
        <result column="yn" property="yn" jdbcType="DECIMAL"/>
      </resultMap>
    

    错误是解析VARCHAR的时候报错,所以找出VARCHAR类型定义的元素。通过对这些元素的对比,发现倒数第二个元素定义是javaType,导致classNotFound。将其改成jdbcType,问题解决。

    相关文章

      网友评论

          本文标题:Cause: org.apache.ibatis.type.Ty

          本文链接:https://www.haomeiwen.com/subject/fyvhqhtx.html