在使用Mybatis进行测试时出现报错:Caused by: java.lang.ClassNotFoundException: Cannot find class: Student

在使用Mybatis进行测试时出现报错:Caused by: java.lang.ClassNotFoundException: Cannot find class: Student

StudentMapper.xml代码

1 <select id="getStudent" resultType="Student">
2     select * from student
3 </select>          

经查找得知是 resultType 出现问题,其值本应该为:

<select id="getStudent" resultType="com.jay.domain.Student">

因使用了别名,进行简化,故查看别名是否出错

<typeAliases>
  <package name="com.jay.dao"/>
</typeAliases>

发现 package 的 name 值写错,正确的应该是

    <typeAliases>
        <package name="com.jay.domain"/>
    </typeAliases>

路径在实体类目录下

重新测试,测试成功!!!

原文地址:https://www.cnblogs.com/Lvzx233/p/13474156.html