在使用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>

路徑在實體類目錄下

重新測試,測試成功!!!

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM