Invalid bound statement (not found)出現原因和解決方法
前言:
想必各位小伙伴在碼路上經常會碰到奇奇怪怪的事情,比如出現Invalid bound statement (not found),那今天我就來分析以下出現此問題的原因,
其實出現這個問題實質就是mapper介面和mapper.xml檔案沒有映射起來,
常見的錯誤如下:
1.mapper.xml中的namespace和實際的mapper檔案不一致
這個問題其實很好解決,瞪大眼睛,仔仔細細看看,到底對不對應不就好了嘛
2.mapper介面中的方法名和mapper.xml中的id標簽不一致
這個問題和上個問題解決方法一樣,仔細對對嘛,這個再對不出來,面壁思過吧,
3.上兩步的問題都沒有,但是還是不行,可能原因就是,沒有構建進去,打開target看看對應的mapper.xml檔案在不在

4.pom.xml檔案中配置resource,不然mapper.xml檔案就會被漏掉!pom.xml的中配置了resource,bug消失了~
<!-- 如果不添加此節點mybatis的mapper.xml檔案都會被漏掉, -->
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/509490.html
標籤:其他
上一篇:二叉樹查找和洗掉指定結點
下一篇:爬蟲高性能相關
