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

MyBatis 抛出异常如下:

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.threegrand.urdm.system.dao.UserDao.saveUser
    at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:184)
    at org.apache.ibatis.binding.MapperMethod.<init>(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(<generated>)
    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(<generated>)
    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)

异常原因:

       前提:  我把持久层 接口和xml映射文件同时放在一起.

       maven项目中, Java目录下默认只编译java文件,其它文件类型都被排除. 所以编译打包时,不会把java目录下的xml文件一起打包. 就会抛出此异常信息; 默认是这样,不过这个是可以通过配置修改的.


异常解决:

      在maven项目中的.pom文件添加以下配置信息即可:

    <build>  
        <resources>  
          <resource>  
            <directory>src/main/java</directory>  
            <includes>  
              <include>**/*.xml</include>  
            </includes>  
          </resource>  
        </resources>  
      </build>  


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值