在使用Maven工程管理工具整合SSM框架时,Mybatis使用逆向工程生成的pojo,mapper接口及映射文件,把mapper接口和映射文件放在DAO工程的同一级src/main/java目录下。正常启动服务器,浏览器执行业务Console控制台抛出异常:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)。

一、异常描述:

  1 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
2 cn.e3mall.mapper.TbItemMapper.selectByExample
3 at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:189)
4 at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:43)
5 at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:58)
6 at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:51)
7 at com.sun.proxy.$Proxy31.selectByExample(Unknown Source)
8 at cn.e3mall.service.impl.ItemServiceImpl.getItemById(ItemServiceImpl.java:34)
9 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
10 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
11 at sun.reflect.DelegatingMethodAccessorImpl.invoke
12 (DelegatingMethodAccessorImpl.java:43)
13 at java.lang.reflect.Method.invoke(Method.java:498)
14 at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection
15 (AopUtils.java:302)
16 at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint
17 (ReflectiveMethodInvocation.java:190)
18 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
19 (ReflectiveMethodInvocation.java:157)
20 at org.springframework.transaction.interceptor.
21 TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
22 at org.springframework.transaction.interceptor.TransactionAspectSupport.
23 invokeWithinTransaction(TransactionAspectSupport.java:281)
24 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke
25 (TransactionInterceptor.java:96)
26 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
27 (ReflectiveMethodInvocation.java:179)
28 at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke
29 (ExposeInvocationInterceptor.java:92)
30 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
31 (ReflectiveMethodInvocation.java:179)
32 at org.springframework.aop.framework.JdkDynamicAopProxy.invoke
33 (JdkDynamicAopProxy.java:208)
34 at com.sun.proxy.$Proxy34.getItemById(Unknown Source)
35 at cn.e3mall.controller.ItemController.getItemById(ItemController.java:27)
36 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
37 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
38 at sun.reflect.DelegatingMethodAccessorImpl.invoke
39 (DelegatingMethodAccessorImpl.java:43)
40 at java.lang.reflect.Method.invoke(Method.java:498)
41 at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke
42 (InvocableHandlerMethod.java:222)
43 at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest
44 (InvocableHandlerMethod.java:137)
45 at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.
46 invokeAndHandle(ServletInvocableHandlerMethod.java:110)
47 at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.
48 invokeHandlerMethod(RequestMappingHandlerAdapter.java:814)
49 at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.
50 handleInternal(RequestMappingHandlerAdapter.java:737)
51 at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle
52 (AbstractHandlerMethodAdapter.java:85)
53 at org.springframework.web.servlet.DispatcherServlet.doDispatch
54 (DispatcherServlet.java:959)
55 at org.springframework.web.servlet.DispatcherServlet.doService
56 (DispatcherServlet.java:893)
57 at org.springframework.web.servlet.FrameworkServlet.processRequest
58 (FrameworkServlet.java:969)
59 at org.springframework.web.servlet.FrameworkServlet.doGet
60 (FrameworkServlet.java:860)
61 at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
62 at org.springframework.web.servlet.FrameworkServlet.service
63 (FrameworkServlet.java:845)
64 at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
65 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
66 (ApplicationFilterChain.java:305)
67 at org.apache.catalina.core.ApplicationFilterChain.doFilter
68 (ApplicationFilterChain.java:210)
69 at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
70 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
71 (ApplicationFilterChain.java:243)
72 at org.apache.catalina.core.ApplicationFilterChain.doFilter
73 (ApplicationFilterChain.java:210)
74 at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal
75 (CharacterEncodingFilter.java:121)
76 at org.springframework.web.filter.OncePerRequestFilter.doFilter
77 (OncePerRequestFilter.java:107)
78 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
79 (ApplicationFilterChain.java:243)
80 at org.apache.catalina.core.ApplicationFilterChain.doFilter
81 (ApplicationFilterChain.java:210)
82 at org.apache.catalina.core.StandardWrapperValve.invoke
83 (StandardWrapperValve.java:222)
84 at org.apache.catalina.core.StandardContextValve.invoke
85 (StandardContextValve.java:123)
86 at org.apache.catalina.authenticator.AuthenticatorBase.invoke
87 (AuthenticatorBase.java:502)
88 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
89 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
90 at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
91 at org.apache.catalina.core.StandardEngineValve.invoke
92 (StandardEngineValve.java:118)
93 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
94 at org.apache.coyote.http11.AbstractHttp11Processor.process
95 (AbstractHttp11Processor.java:1041)
96 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process
97 (AbstractProtocol.java:603)
98 at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
99 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
100 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
101 at java.lang.Thread.run(Thread.java:748)

二、错误分析:

       此异常的原因是由于mapper接口编译后在同一个目录下没有找到mapper映射文件而出现的。由于maven工程在默认情况下src/main/java目录下的mapper文件是不发布到target目录下的。

三、解决办法:

方法1:将Mapper映射文件放到src/main/resources目录下,然后再建一个和mapper接口所在的包名一样的包。

方法2:在此工程pom文件中配置一下resources。

  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>

四、注意事项:

原配置文件默认放在src/main/resources目录下,这样配置了之后,就指定src/main/java它是资源目录,src/main/resources目录就会不起作用了。如果不想这样,需要在配置中再加上一个resource节点,把src/main/resources目录也添加进来,即:

  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 <resource>
13 <directory>src/main/resources</directory>
14 <includes>
15 <include>**/*.properties</include>
16 <include>**/*.xml</include>
17 </includes>
18 <filtering>false</filtering>
19 </resource>
20 </resources>
21 </build>

HTTP Status 500 - Request processing failed; nested exception is org.apache.ibatis.binding.BindingException的更多相关文章

  1. HTTP Status 500 - Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    今天整合ssm框架 时 遇到的问题 困扰我好长时间     原因就是  mapper文件 没有被加载进来 但是 为什么没有被加载进来呢  因为中间的配置文件出了一些问题 网上大多数说法是   在pom ...

  2. Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid b

    Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid b ...

  3. Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement

    原因: 此异常的原因是由于mapper接口编译后在同一个目录下没有找到mapper映射文件而出现的.由于maven工程在默认情况下src/main/java目录下的mapper文件是不发布到targe ...

  4. Exception:Request processing failed; nested exception is org.apache.ibatis.binding.BindingException

    异常 在测试Spring MVC+Mybatis整合时,运行 Maven build -> tomcat7:Run 遇到如下异常 从异常信息上看,是找不到mapper对应的xml文件,于是我到t ...

  5. HTTP Status 500 - Request processing failed; nested exception is org.springframework.jdbc.BadSqlGram

    HTTP Status 500 - Request processing failed; nested exception is org.springframework.jdbc.BadSqlGram ...

  6. HTTP Status 500 - Request processing failed; nested exception is org.hibernate.exception.GenericJDBCException: could not execute statement

    1.什么操作出现:当我在项目中添加产品或者修改时,浏览器出现HTTP Status 500 - Request processing failed; nested exception is org.h ...

  7. HTTP Status 500 - Request processing failed; nested exception is java.lang.NullPointerException

    HTTP Status 500 - Request processing failed; nested exception is java.lang.NullPointerException type ...

  8. SpringMvc错误:HTTP Status 500 - Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is n

    HTTP Status 500 - Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemExc ...

  9. HTTP Status 500 - Request processing failed; nested exception is java.lang.IllegalArgumentException: Control character in cookie value or attribute.

    HTTP Status 500 - Request processing failed; nested exception is java.lang.IllegalArgumentException: ...

随机推荐

  1. bzoj千题计划155:bzoj3543: [ONTAK2010]Garden

    http://www.lydsy.com/JudgeOnline/problem.php?id=3543 枚举每一个点,作为左下角 然后枚举 相同的x坐标,y坐标 少的那个 作为另一个角 二分判断另外 ...

  2. Java并发编程原理与实战四十二:锁与volatile的内存语义

    锁与volatile的内存语义 1.锁的内存语义 2.volatile内存语义 3.synchronized内存语义 4.Lock与synchronized的区别 5.ReentrantLock源码实 ...

  3. 经典Dialog插件Layer

    Github上只有一个test,所以最好还是到官网去学习,官网的示例写的很详尽,难得一见的设计思路和灵活性都极好的插件.下面是我自己test过的demo <!DOCTYPE html> & ...

  4. git提示error setting certificate verify locations解决办法

    先打开git bash窗口 执行命令: git config --system http.sslcainfo "C:\Program Files (x86)\git\bin\curl-ca- ...

  5. 【实操笔记】MySQL主从同步功能实现

    写在前边: 这两天来了个需求,配置部署两台服务器的MySQL数据同步,折腾了两天查了很多相关资料,一直连不上,后来发现其实是数据库授权的ip有问题,我们用的服务器是机房中的虚拟机加上反向代理出来的,坑 ...

  6. 解析XML文件的几种常见操作方法:DOM/SAX/DOM4j

    <?xml version="1.0" encoding="utf-8"?> <root> <class name="c ...

  7. 计算广告学-多点归因模型(Multi-Touch Attribution Model)

    计算广告学中的一个重要的问题是, 如果用户产生了一次转化(conversion, 比如购买, 注册等), 且该用户在转化之前看过大量不同频道(比如搜索, 展示, 社交等等)的广告, 那么我们如何确定是 ...

  8. UCenter在JAVA项目中实现的单点登录应用实例

    Comsenz(康盛)的UCenter当前在国内的单点登录领域占据绝对份额,其完整的产品线令UCenter成为了账号集成方面事实上的标准. 基于UCenter,可以将Comsenz旗下的Discuz! ...

  9. 【CodeForces】600 E. Lomsat gelral (dsu on tree)

    [题目]E. Lomsat gelral [题意]给定n个点的树,1为根,每个点有一种颜色ci,一种颜色占领一棵子树当且仅当子树内没有颜色的出现次数超过它,求n个答案——每棵子树的占领颜色的编号和Σc ...

  10. 【leetcode 简单】 第八十八题 猜数字大小

    我们正在玩一个猜数字游戏. 游戏规则如下: 我从 1 到 n 选择一个数字. 你需要猜我选择了哪个数字. 每次你猜错了,我会告诉你这个数字是大了还是小了. 你调用一个预先定义好的接口 guess(in ...