Result Maps collection already contains value for com.changemax.mas.mapper.QaMapper.BaseResultMap 解决
错误信息:
Error creating bean with name 'qaService': Unsatisfied dependency expressed through field 'qaMapper': No qualifying bean of type [com.changemax.mas.mapper.QaMapper] found for dependency [com.changemax.mas.mapper.QaMapper]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.changemax.mas.mapper.QaMapper] found for dependency [com.changemax.mas.mapper.QaMapper]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
解决过程:
今天修改了一下mysql数据库中的一些表字段信息,那么就使用了Mybatis的逆向工程工具generatorSqlmapCustom从新生成了一下po,和mapper,但是发现它老是在报同样的错误,说id重复,那么我就去qaMapper.xml文件中进行查找:
发现,在同一个mapper.xml文件中,确实出现了两个id一样的为“BaseResultMap”的resultMap:如下
经过一番仔细的检查,发现原来是逆向工程工具的配置文件中添加了两个一样的表:
而对于添加两个一样的table进行逆向生成代码,代码不会进行覆盖操作,而是进行叠加操作,所以导致生成了两个一样id的resultMap。