溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Maven 引入SSM框架出現(xiàn)的異常之BindingException

發(fā)布時間:2020-08-04 02:37:42 來源:網(wǎng)絡(luò) 閱讀:219 作者:ywb_4185 欄目:編程語言

IntelliJ IDEA 開發(fā)Spring-mvc +mybits 項目時,啟動tomcat后瀏覽器發(fā)送請求后收到了500服務(wù)器錯誤,錯誤如下:

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

網(wǎng)上搜了一下,問題出在沒找到Mapper XML 文件
經(jīng)過多次嘗試發(fā)現(xiàn)出現(xiàn)這個問題的原因在于mybatis逆向生成mapper接口和mapper.xml文件放在了同一個文件夾中,在編譯打包時沒法加載mapper.xml文件。

兩種解決方式
  • 方式一:

    • mapper接口和mapper.xml文件都在同一個路徑下時,在pom.xml文件添加如下內(nèi)容: 問題解決
      <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下的文件直接讀取進去,就不會出現(xiàn)找不到mapper.xml的錯誤
向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI