org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)新的异常解决方案

首先异常如下:

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.threegrand.urdm.system.dao.UserDao.saveUser
    at org.apache.ibatis.binding.MapperMethod$SqlCommand.(MapperMethod.java:184)
    at org.apache.ibatis.binding.MapperMethod.(MapperMethod.java:38)
    at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:49)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:42)
    at com.sun.proxy.$Proxy19.saveUser(Unknown Source)
    at com.threegrand.urdm.system.service.UserService.saveUser(UserService.java:20)
    at com.threegrand.urdm.system.service.UserService$$FastClassBySpringCGLIB$$caacda27.invoke()
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:266)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)
    at com.threegrand.urdm.system.service.UserService$$EnhancerBySpringCGLIB$$33d9263b.saveUser()
    at com.threegrand.urdm.userservice.UserServiceTest.testAdd(UserServiceTest.java:35)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    。。。。

昨天下午出现的,第一次遇到这个错误,非常神奇的与网上的经验不同,他们的解决方法我都一一测试过了,还是不好使:
方案一
方案二
方案三
我主要从后面两个方案中获得灵感的,首先看我的配置,
我使用的是mybatisRepository注解,将mybatis接口注入:

  
    <bean id="sqlSessionFactory1" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="configLocation" value="classpath:/mybatis/configuration-mybatis.xml"/>
        
        <property name="mapperLocations">
            <list>
                <value>classpath*:/mapper/UserDao.xmlvalue>
            list>
        property>
        <property name="configurationProperties">
            <props>
                
                <prop key="mapUnderscoreToCamelCase">trueprop>
            props>
        property>
    bean>

之前使用mybatis plugins将所有潜在的错误都排查过了,当然还有启动日志,还重写了项目,并且检查了每个可能发生错误的配置,但是还是不好使,我把xml文件和Dao接口放在一个包名下,然后让注解去扫描,进行动态代理,但是依然找不到问题所在,我使用debug模式模拟方法调用还是不行。听说要将xml文件放到config-mybatis.xml中的mappers中,但是还是不好使,在idea 下的代码资源文件中和测试资源文件中都试过了,不好使,很衰的样子,我跟另一个朋友也讨论了,但是没有结果。

后来把mapper映射文件放到资源目录下,进行扫描竟然好使了。
如图:
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)新的异常解决方案_第1张图片

你可能感兴趣的:(mybatis专题,spring框架专题)