zoukankan      html  css  js  c++  java
  • MyBatis报错找不到对应的JavaBean类

    错误信息

    org.apache.ibatis.exceptions.PersistenceException: 
    ### Error building SqlSession.
    ### The error may exist in com/bucai/one_to_one/OneToOneMapper.xml
    ### The error occurred while processing mapper_resultMap[oneToOne]
    ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'com/bucai/one_to_one/OneToOneMapper.xml'. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'card'.  Cause: java.lang.ClassNotFoundException: Cannot find class: card

    Mapper文件

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE mapper
            PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
            "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
    <mapper namespace="com.bucai.table01.OneToOneMapper">
    <!--    配置字段和实体对象属性的映射关系-->
        <resultMap id="oneToOne" type="card">
            <id column="cid" property="id"/>
            <result column="number" property="number"/>
            <!--association:配置被包含对象的映射关系
            property:被包含对象的变量名
            Java type :被包含对象的数据类型-->
            <association property="p" javaType="person">
                <id column="pid" property="id"/>
                <result column="name" property="name"/>
                <result column="age" property="age"/>
            </association>
        </resultMap>
        <select id="selectAll" resultMap="oneToOne">
            SELECT c.id cid,number,pid,NAME,age FROM card c,person p WHERE c.pid=p.id
        </select>
    
    </mapper>

    解决方法:在type和JavaType后面写上完整路径

  • 相关阅读:
    CLR基础
    Windows7下使用Shell32.dll出现没有实现接口的错误的解决办法
    Python学习
    Python学习
    开发常识之Linux用户及其权限管理
    (转)简单明晰的Jupyter Notebook总结与指南
    Oracle系列数据库版本区别
    应用场景区别-MongoDB与MySQL的选择比较
    我的博客(个人空间)地址更新说明
    (转)Spark与Map-Reduce区别对比
  • 原文地址:https://www.cnblogs.com/bucai/p/13750027.html
Copyright © 2011-2022 走看看