报错信息:
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: org.apache.ibatis.reflection.ReflectionException: Error instantiating interface com.wanghwei.dao.IUserMapper with invalid types () or values (). Cause: java.lang.NoSuchMethodException: com.wanghwei.dao.IUserMapper.<init>()
### The error may exist in mapper/UserMapper.xml
### The error may involve com.wanghwei.dao.IUserMapper.getUserList
### The error occurred while handling results
### SQL: select * from smbms_user
### Cause: org.apache.ibatis.reflection.ReflectionException: Error instantiating interface com.wanghwei.dao.IUserMapper with invalid types () or values (). Cause: java.lang.NoSuchMethodException: com.wanghwei.dao.IUserMapper.<init>()
解决方案:
网上说的有3中解决方案:
1) Bean函数中的get/set方法与成员变量不一。
2) 构造函数被重载过,但是没有空的构造函数。这种情况我后来有意的试过我就把一个无参的构造函数删除掉,只留一个有参的构造函数是可以运行的,可能是偶然发生
3) 最好不要使用简单类型,如int, long等,改用对象模式Integer, Long等。在写条件查询时会用到判断<if xxx != null > … </if>的
以上3种都没能解决我的Error,回头一看核心配置文件,×,别名的类型指定错了,俩大嘴巴子扇的瞬间清醒
<typeAliases>
<typeAlias type="com.wanghwei.dao.IUserMapper" alias="User" />
</typeAliases>
4) 自己的解决方案
<typeAliases>
<typeAlias type="com.wanghwei.pojo.User" alias="User" />
</typeAliases>
浙公网安备 33010602011771号