在使用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>
路徑在實體類目錄下
重新測試,測試成功!!!