欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

错误:org.apache.ibatis.builder.BuilderException: Ambiguous collection type for property ‘children‘.

程序员文章站 2022-07-15 13:08:51
...

写了一个多表查询功能后,项目报错:

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">
相关标签: java spring