关于mybatis的mapper.xml问题,求大神解答

LiZhuzhuGo 2021-05-03 05:30:51
今天我用springboot和mybatis做了一个小项目,用逆向工程生成了实体类,mapper,和mapper.xml。我用注解写的普通查询都正常使用,当我用到mapper里面自动生成的mapper的增删改查的方法的时候就会报找不到xml的错误,于是我在yml文件中配置了 mapper-locations: classpath:mybatis/mapper/*.xml这个路劲,结果出现了新的错误,求大神解答啊
第一行完整报错是这样的:org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'adminController': Unsatisfied dependency expressed through field 'iCarDetail'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'carDetailImpl': Unsatisfied dependency expressed through field 'carDetailMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'carDetailMapper' defined in file [C:\Users\留不住的年华\Desktop\dragon-f\target\classes\teach\aistar\mapper\CarDetailMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [C:\Users\留不住的年华\Desktop\dragon-f\target\classes\mybatis\mapper\CarBrandsMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'file [C:\Users\留不住的年华\Desktop\dragon-f\target\classes\mybatis\mapper\CarBrandsMapper.xml]'. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for teach.aistar.mapper.CarBrandsMapper.BaseResultMap

...全文
374 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
木子0204 2021-05-07
  • 打赏
  • 举报
回复
估计是路径不对吧
li905663280 2021-05-04
  • 打赏
  • 举报
回复
xml文件中存在重名对象,保持名称不要一样即可正常启动。因为我再次使用逆向工程生成mapper接口和xml文件时,忘了删除原来的xml文件,新生成的与旧的同时出现旧重复了https://blog.csdn.net/maoyuanming0806/article/details/77870345
韩_师兄 2021-05-04
  • 打赏
  • 举报
回复
引用 2 楼 七国的天下,我要九十九 的回复:
Unsatisfied dependency expressed through field 'iCarDetail
这个属性是不是找不到,所以报错的.
韩_师兄 2021-05-04
  • 打赏
  • 举报
回复
Unsatisfied dependency expressed through field 'iCarDetail
a1767028198 2021-05-03
  • 打赏
  • 举报
回复
Result Maps collection already contains value for teach.aistar.mapper.CarBrandsMapper.BaseResultMap

50,526

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧