当类和mybatis的xml放在其他module时,如你的resultType是这样写:
<select id="selectall" resultType="student">
select id,age from student
</select>
那么会报错:
Caused by: java.lang.ClassNotFoundException: Cannot find class: student
at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:200) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:89) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.io.Resources.classForName(Resources.java:261) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:116) ~[mybatis-3.4.6.jar:3.4.6]
... 79 common frames omitted
明显写的是mybatis问题,那么就只有xml里找不到类了!!!!毕竟是这个地方用了mybatis
如果你的类是放在与xml相同的module,这样写是没问题的!!直接可以根据student这个类名找到当前module下的类。
但是你的类是不在当前module,就自然找不到。原因应该是如果不具体指明类的位置,只提供类名。xml只会在当前module下找!!
所以你要具体指明类的位置
<select id="selectall" resultType="com.hzh.entitys.entitys.student">
select id,age from student
</select>
这样,完美解决!!!!!!!!!!!!!!!!!!!!!!!!!!!