spring,mbatis整合报错:Mapped Statements collection does not contain
来源:互联网 发布:javascript cookie实例 编辑:程序博客网 时间:2024/05/21 18:41
今天在做spring+mybatis整合时做了个测试案例,出现错误Mapped Statements collection does not contain value for com.java.mapper.UserMapper。错误信息指向mapper.xml映射文件和接口不匹配。上网找了一下大多都是以下几种解释:
1、mapper.xml中没有加入namespace
2、mapper.xml中的方法和接口mapper的方法不对应
3、mapper.xml没有加入到mybatis-config.xml中(即总的配置文件),例外:配置了mapper文件的包路径的除外
然而我的整合中都已经满足了以上的几个条件,还是报相同的错误,绞尽脑汁,头皮发麻。还有说没有编译通过的,查看了工作空间里也已经编译过了,最后解决问题只是在spring和mybatis整合配置文件中加了这一行:
<!-- spring和mybatis配置 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="typeAliasesPackage" value="com.java.pojo"></property>
<!-- 自动扫描mapping.xml文件 -->
<property name="mapperLocations" value="classpath:com/java/pojo/*.xml"></property>
</bean>
一开始以为只需要在配置文件中自动扫描mapper的路径就行了,也就是<mybatis:scan base-package="com.java.mapper" />。原来这个只是扫描的是mapper接口文件,如果遇到和我相同的问题可以试一下加入上面的配置信息看看可不可行
- spring,mbatis整合报错:Mapped Statements collection does not contain
- Spring+Mybatis整合报错Mapped Statements collection does not contain value原因之一
- spring+mybatis项目搭建测试报错Mapped Statements collection does not contain value for
- Spring整合MyBatis错误:Mapped Statements collection does not contain value for
- Mapped Statements collection does not contain value
- mybatis报错Mapped Statements collection does not contain value for com.inter.IOperation.getAllItems
- 报错:Mapped Statements collection does not contain value for com.fzl.organation.vo.OrganizationMapping
- mybatis报错:java.lang.IllegalArgumentException: Mapped Statements collection does not contain
- Mybatis报错—— Mapped Statements collection does not contain value for com.mapper.DepartmentMapper
- 使用Maven构建项目,spring整合mybatis发生错误:Mapped Statements collection does not contain value for
- mybatis+springMVC整合出现Mapped Statements collection does not contain value for ***
- myBatis配置报Mapped Statements collection does not contain value for
- batis 错误 Mapped Statements collection does not contain value for
- mybatis错误 Mapped Statements collection does not contain value for
- Mapped Statements collection does not contain value for...
- Mapped Statements collection does not contain value for RelateMarketingMapper....解决办法
- mybatis错误 Mapped Statements collection does not contain value for
- mybatis错误 Mapped Statements collection does not contain value for
- windows获取网卡信息并判断是否是物理网卡 网络适配器的判断
- vim
- 适配iOS 11和iPhone X——导航栏、UITableView
- Linux命令之 du命令
- 前端使用的network
- spring,mbatis整合报错:Mapped Statements collection does not contain
- 曙光HPC首席科学家吉青:高性能计算不只AI,曙光更注重技术创新
- RecyclerView的上拉加载
- C/C++之回调函数
- 一次web项目首页压测记录(未完)
- MVP
- x = data[:,0] 的含义
- GC区分垃圾的算法及Java虚拟机中的分代
- 阿里云天气api调用方法。