mybatis collection配置
最近在学习mybaitis 按照文档配置 遇到一个一对多的问题 No typehandler found for property userRoles
实体类:
private String username;
private String password;
private Date registerTime;
private List<UserRole> userRoles;
mybatis mapper文件
<resultMap type="com.learn.model.User" id="userResultMap2"
extends="baseResultMap">
<collection property="userRoles" javaType="list"
ofType="com.learn.model.UserRole">
<id property="id" column="id" />
<result column="role_id" property="roleId" />
<result property="userId" column="user_id" />
</collection>
</resultMap>
<select id="getAll2" resultMap="userResultMap2">
SELECT u.username, u.password,
u.register_time, ur.id, ur.user_id, ur.role_id
FROM USER u
JOIN
user_role ur ON u.username = ur.user_id
</select>
出现问题:
No typehandler found for property userRoles
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in file [D:\maven\target\classes\spring\applicationContext-dao.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\maven\target\classes\com\learn\mapper\UserMapper.xml]'; nested exception is java.lang.IllegalStateException: No typehandler found for property userRoles
请问,怎么会出现No typehandler found for property userRoles的问题呢?