异常-----------------------------> org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.taotao.mapper.TbItemMapper.selectByExample] with root cause

-----------------------------

分析:

  根据报错的信息, 找不到Mapper映射文件, 但是工程中明明有, 所以只可能是没有引用过来, 于是查看编译过后的文件目录, 果然找不到映射文件:

    

解决:

  在mapper的pom.xml文件中添加以下代码 [ 注: 本异常是在使用了分布式工程结构, 使用maven工具生成的工程结构会出现, 其他情况不适合 ]

 1 <!-- 如果不添加此节点mybatis的mapper.xml文件都会被漏掉。 -->
 2     <build>
 3         <resources>
 4             <resource>
 5                 <directory>src/main/java</directory>
 6                 <includes>
 7                     <include>**/*.properties</include>
 8                     <include>**/*.xml</include>
 9                 </includes>
10                 <filtering>false</filtering>
11             </resource>
12         </resources>
13     </build>

 再次编译: 有mapper.xml映射文件, 测试成功

    

 

posted @ 2017-03-25 17:03  半生戎马,共话桑麻、  阅读(373)  评论(0)    收藏  举报
levels of contents