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

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

我們提供的服務有:成都網(wǎng)站建設、做網(wǎng)站、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認證、濱湖ssl等。為成百上千家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務,是有科學管理、有技術的濱湖網(wǎng)站制作公司

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的錯誤

本文標題:如何解決Maven引入SSM框架出現(xiàn)的異常問題
當前鏈接:http://bm7419.com/article48/pceghp.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站策劃域名注冊、建站公司外貿(mào)網(wǎng)站建設、Google品牌網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站建設網(wǎng)站維護公司