关于mybatis的mapper.xml问题,求大神解答
今天我用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


第一行完整报错是这样的: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

...全文
相关推荐
详解mybatis-plus的 mapper.xml 路径配置的坑
本文将详细讲解mybatis-plus的mapper.xml路径配置的常见问题,并提供解决策略。首先,我们需要理解Mybatis-Plus的工作原理。
IntelliJ IDEA修改了mybatis mapper xml后不用重启tomcat,自动热发布 热更新 热部署.zip
在开发Java Web应用程序时,尤其是使用Mybatis作为持久层框架的时候,经常遇到的一个问题是:当我们在IntelliJ IDEA中修改了Mapper XML文件后,需要手动重启Tomcat服务器才能看到改动的效果
mybatis-通用Mapper-逆向工程-代码生成工具
在实际使用过程中,阅读README.md文件是非常重要的,它通常包含了详细的使用指南、示例代码以及常见问题解答。
Mybatis查不到数据查询返回Null问题
可以尝试将参数硬编码到SQL中,看看是否能获取到数据,以排除参数传递问题。4. 检查Mapper文件中的XML映射,确保字段和实体类属性的对应关系是正确的,包括大小写和类型。5.
使用mybatis-plus报错Invalid bound statement (not found)错误
当遇到此类问题时,首先检查上述可能的原因,逐一排查。如果问题仍然存在,可以尝试查看Mybatis-Plus的官方文档或社区论坛,通常会有详细的解答和解决方案。


