SSM整合junit单元测试之org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

想用SSM做一点小测试,项目整合完毕,直接使用junit测试mybatis,出现如下错误(SuperTest类中进行了spring运行环境加载):

 解决思路:

检查mapper接口与mapper.xml文件名、namespace、statement的id与mapper接口中的方法名

然而发现并没有问题,之前使用Eclipse时遇到过mapper.xml不发布的问题,猜想可能idea也存在这个问题,检查targer目录,发现确实是mapper.xml未发布

需要在maven的<build></build>标签中配置一下内容:

<resources>  
     <resource>  
         <directory>${basedir}/src/main/java</directory>  
               <includes>  
                   <include>**/*.xml</include>  
               </includes>  
      </resource>  
</resources>

插入完毕之后重新测试,可以在target目录下看到mapper.xml已经发布,程序正常运行。

 

猜你喜欢

转载自www.cnblogs.com/alphajuns/p/11785541.html
今日推荐