1. 程式人生 > >關於Mybatis出現:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

關於Mybatis出現:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

最近一直都加班,但是呢

在這裡插入圖片描述

出現的問題以及解決方案:框架是(SSM)

關於Mybatis出現的一些繫結問題哈:

直接上截圖,錯誤程式碼:
在這裡插入圖片描述

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): cn.e3mall.mapper.TbItemMapper.selectByPrimaryKey
	org.
springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:981) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:860) javax.servlet.http.HttpServlet.service(HttpServlet.java:621) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.
java:845) javax.servlet.http.HttpServlet.service(HttpServlet.java:728) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121) org.springframework.web.filter.OncePerRequestFilter.
doFilter(OncePerRequestFilter.java:107) root cause

首先說下問題出在哪裡啊:
a).看下你的掃描的applicationContext.xml檔案中mappper的路徑

在這裡插入圖片描述
看下是不是和你的mapper路徑是否一樣

然後去你的資料夾看下你的mapper檔案中是否含有的xml檔案(在這裡就不貼圖片了啊)
如果沒有的話,給你兩種解決方案哈:

b).給你的

src/main/resources資料夾加上一個同樣的目錄給xml扔進去即可

c).
在你的

pom.xml檔案中新增如下程式碼:
<!-- 如果不新增此節點mybatis的mapper.xml檔案都會被漏掉。 -->
	<build>
		<resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>
	</build>

然後重新編譯下,然後再去專案中物件的mapper檔案下看看是否有xml檔案

一看,檔案存在,好了,問題解決 回家碎覺

文章來源網路,版權歸作者本人所有,如侵犯到原作者權益,請與我們聯絡刪除或授權事宜
如果有誤,請聯絡作者更改,謝謝,本人微信:void666666