溫馨提示×

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

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

如何解決Maven引入SSM框架出現(xiàn)的異常問(wèn)題

發(fā)布時(shí)間:2020-05-27 21:20:25 來(lái)源:億速云 閱讀:275 作者:鴿子 欄目:編程語(yǔ)言

IntelliJ IDEA 開(kāi)發(fā)Spring-mvc +mybits 項(xiàng)目時(shí),啟動(dòng)tomcat后瀏覽器發(fā)送請(qǐng)求后收到了500服務(wù)器錯(cuò)誤,錯(cuò)誤如下:

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)上搜了一下,問(wèn)題出在沒(méi)找到Mapper XML 文件
經(jīng)過(guò)多次嘗試發(fā)現(xiàn)出現(xiàn)這個(gè)問(wèn)題的原因在于mybatis逆向生成mapper接口和mapper.xml文件放在了同一個(gè)文件夾中,在編譯打包時(shí)沒(méi)法加載mapper.xml文件。

兩種解決方式
  • 方式一:

    • mapper接口和mapper.xml文件都在同一個(gè)路徑下時(shí),在pom.xml文件添加如下內(nèi)容: 問(wèn)題解決
      <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下同級(jí)包下,編譯打包時(shí)會(huì)把resources下的文件直接讀取進(jìn)去,就不會(huì)出現(xiàn)找不到mapper.xml的錯(cuò)誤

向AI問(wèn)一下細(xì)節(jié)

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

AI