Spring整合MyBatis错误:org.apache.ibatis.binding.BindingException
来源:互联网 发布:2017网络暴力最新事件 编辑:程序博客网 时间:2024/03/29 16:19
MyBatis Mapper使用Spring注入: applicationContext.xml
<!--这一段让我们的MapperInterface能够最终在Spring中生成Bean最后被AutoWired--> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.zmx.ssm.user.mapper" /> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/> </bean>
使用上面方式注入时需要注意下面问题:
- interface = com.zmx.ssm.user.mapper.UserMapper.class
- mapper file = com.zmx.ssm.user.mapper.UserMapper.xml
- mapper namespace = com.zmx.ssm.user.mapper.UserMapper
这三者应该设置为相同,否则会出现:org.apache.ibatis.binding.BindingException: Invalid bound statement 异常。
使用上述配置,-mapper file也可以和-interface、-namespace不同的(注意:interface和namespace必须相同),但这时需要进行配置。指明mapper file的位置。
配置如下(两种方式):
方式一:
1.在MyBatis配置文件中添加mappers:mybatis-config.xml
<mappers> <mapper resource="mapper/UserMapper.xml" /> </mappers>
2.使用configLocation,在Spring配置文件中添加MyBatis配置文件的引用:applicationContext.xml
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <!--指定了Mybatis配置文件的路径--> <property name="configLocation" value="classpath:mybatis-config.xml"/> </bean>
方式二:
使用mapperLocations,MyBatis-Spring会自动地扫描该路径下的所有Mapper文件: applicationContext.xml
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <!--等价于上面的配置--> <property name="mapperLocations" value="classpath:/mapper/*Mapper.xml"/> <property name="typeAliasesPackage" value="com.zmx.ssm.user.domain" /> </bean>
- Spring整合MyBatis错误:org.apache.ibatis.binding.BindingException
- org.apache.ibatis.binding.BindingException spring springMVC mybatis 整合
- mybatis整合springmvc时的错误org.apache.ibatis.binding.BindingException: Invalid bound statement (not found
- 当mybatis整合spring后出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
- spring+mybatis整合报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- 关于mybatis+spring的org.apache.ibatis.binding.BindingException: Invalid bound statement错误
- mybatis 异常:org.apache.ibatis.binding.BindingException
- org.apache.ibatis.binding.BindingException
- org.apache.ibatis.binding.BindingException
- 关于mybatis “org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)” 错误的问题。
- mybatis绑定错误:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- mybatis绑定错误:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- Mybatis错误org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- mybatis错误:Request processing failed; nested exception is org.apache.ibatis.binding.BindingException
- 关于mybatis “org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)” 错误的问题
- 关于mybatis “org.apache.ibatis.binding.BindingException: Invalid bound statement (
- Mybatis异常解决之--org.apache.ibatis.binding.BindingException
- mybatis 报错org.apache.ibatis.binding.BindingException
- 【MySQL 01】查询--总结
- Android 防止一个控件被过快重复点击
- Test for Job(topo+动态规划)
- C++ 编程题练习-输出200(10-1)
- ThinkPHP find方法 查询一条数据记录
- Spring整合MyBatis错误:org.apache.ibatis.binding.BindingException
- hdu 1050
- JSP中post和get乱码解决方法
- 网页分享到微信后不能从朋友圈打开
- 调用caffe进行网络训练(caffe.cpp 解析)
- 第二次考试 (图论)第一题 劣质的草
- ttf字体包瘦身,ttf字体包提取字体——杨小辉
- Havel-Hakimi定理
- 支付系统对账算法优化方案