温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何解决Maven引入SSM框架出现的异常问题

发布时间:2020-05-27 21:20:25 来源:亿速云 阅读:262 作者:鸽子 栏目:编程语言

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

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文件添加如下内容: 问题解决
      <build>
          <resources>
                  <resource>
                          <directory>src/main/java</directory>
                          <includes>
                                  <include>**/*.properties</include>
                                  <include>**/*.xml</include>
                          </includes>
                          <filtering>false</filtering>
                  </resource>
          </resources>
      </build>
  • 方式二:
    • 将逆向生成的mapper和mapper.xml文件分别放在main/java和main/resources下同级包下,编译打包时会把resources下的文件直接读取进去,就不会出现找不到mapper.xml的错误

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI