Exception in thread "main" org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
先贴配置:
<!-- myBatis 配置 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="configLocation" value="classpath:mybatis-config.xml"/> <property name="dataSource" ref="dataSource"/> <property name="mapperLocations" value="classpath*:com/haoyin/logic/dao/*.xml"/> </bean> <!-- 配置sqlSessionTemplate --> <bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate"> <constructor-arg index="0" ref="sqlSessionFactory" /> </bean> <!-- mybatis自动实现dao--> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.haoyin.logic.dao"/> </bean>
网上说上面最后错误,我这里是指定对的, sqlSessionFactory里的mapperLocations也是对的.
Exception in thread "main" org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.haoyin.logic.dao.UserLoginDao.getTokenByUid at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:196) at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:44) at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:59) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52) at com.sun.proxy.$Proxy11.getTokenByUid(Unknown Source) at com.haoyin.logic.service.UserLoginServiceImpl.authenticate(UserLoginServiceImpl.java:20) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at com.sun.proxy.$Proxy15.authenticate(Unknown Source) at com.haoyin.logic.service.UserLoginServiceTest.main(UserLoginServiceTest.java:19)
import com.haoyin.logic.bean.UserLogin; import org.apache.ibatis.annotations.Param; /** * Created by dong on 2016/1/23. */ public interface UserLoginDao { String getTokenByUid(@Param("uid")String uid); String update(@Param("userLogin")UserLogin userLogin); }
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.haoyin.logic.dao.UserLoginDao"> <select id="getTokenByUid" resultType="string"> SELECT token FROM v1_userLogin WHERE uid = (#{uid}) </select> <update id="update"> UPDATE v1_userLogin <set> <if test="token != null">token = (#{token}),</if> <if test="expire != null">expire = (#(expire)),</if> <if test="lastAccessTimestamp != null">lastAccessTimestamp = (#(lastAccessTimestamp)) </if> </set> WHERE uid = (#{uid}) </update> </mapper>
<divclass='ref'><divclass='ref'>
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。