Maven引入SSM框架出现的异常之BindingException

IntelliJ IDEA 开发Spring-mvc +mybits 项目时,启动tomcat后浏览器发送请求后收到了500服务器错误,错误如下:

成都创新互联公司主营覃塘网站建设的网络公司,主营网站建设方案,app开发定制,覃塘h5微信小程序开发搭建,覃塘网站营销推广欢迎覃塘等地区企业咨询

HTTP Status 500 - Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.creditease.proxymanager.dao.ProxyInfoDAO.getProxyInfo

type Exception report

message Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.creditease.proxymanager.dao.ProxyInfoDAO.getProxyInfo

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.creditease.proxymanager.dao.ProxyInfoDAO.getProxyInfo
    org.springframework.web.servlet.FrameworkServlet.proce***equest(FrameworkServlet.java:982)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.creditease.proxymanager.dao.ProxyInfoDAO.getProxyInfo

网上搜了一下,问题出在没找到Mapper XML 文件
经过多次尝试发现出现这个问题的原因在于mybatis逆向生成mapper接口和mapper.xml文件放在了同一个文件夹中,在编译打包时没法加载mapper.xml文件。

两种解决方式
  • 方式一:

    • mapper接口和mapper.xml文件都在同一个路径下时,在pom.xml文件添加如下内容: 问题解决
      
          
                  
                          src/main/java
                          
                                  **/*.properties
                                  **/*.xml
                          
                          false
                  
          
      
  • 方式二:
    • 将逆向生成的mapper和mapper.xml文件分别放在main/java和main/resources下同级包下,编译打包时会把resources下的文件直接读取进去,就不会出现找不到mapper.xml的错误

网页题目:Maven引入SSM框架出现的异常之BindingException
分享链接:http://scyanting.com/article/ijchii.html