Mybatis报错 Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'UserEntity'

寻龙剑侠
发布于 2024-11-08 / 33 阅读
0

Mybatis报错 Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'UserEntity'

问题描述:

在mapper.xml中重新声明了一个<resultMap type="classNameVo" id="classNameVoResult"></resultMap>,运行项目后报错。这个classNameVo类不是和实体类同在domain包

//错误
Caused by: java.lang.RuntimeException: Failed to parse mapping resource: 'file [...Mapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'file [...Mapper.xml]'. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'classNameVO'.  Cause: java.lang.ClassNotFoundException: Cannot find class: classNameVO

实际是mybatis没有自动扫描到这个类,因此报错。

解决办法是:<resultMap type="cn.xx.xx.vo.classNameVo" id="classNameVoResult"></resultMap> 写全包路径即可