写了一个多表查询功能后,项目报错:
Caused by: org.apache.ibatis.builder.BuilderException: Ambiguous collection type for property 'children'. You must specify 'javaType' or 'resultMap'.
at org.apache.ibatis.builder.xml.XMLMapperBuilder.validateCollection(XMLMapperBuilder.java:415)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.processNestedResultMappings(XMLMapperBuilder.java:401)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildResultMappingFromContext(XMLMapperBuilder.java:383)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:280)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:253)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElements(XMLMapperBuilder.java:245)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:118)
... 77 common frames omitted
注意:Mapper.xml文件中 resultMap的Type类型和方法的返回值是否相同。
Mapper接口:
List<SubjectVo> selectNestedList();
错误写法:
<resultMap id="selectNestedListMap" type="com.jie.car.service.edu.entity.Subject">
修改为:
<resultMap id="selectNestedListMap" type="com.jie.car.service.edu.entity.Vo.SubjectVo">