Maven 遇到mybatis 發生org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
阿新 • • 發佈:2019-01-24
最近在做一個專案用到了spring+springMVC+mybatis+maven 的專案。第一次接觸到maven構建和使用idea。遇到了一個問題,說實話自己被這個問題困住了好久。網上查了好久,也沒有找到。好了,貼一下錯誤。
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.bigHero.doris.mapper.UserOperationMapper.user_register_check
at org.apache.ibatis.binding.MapperMethod $SqlCommand.<init>(MapperMethod.java:178) ~[mybatis-3.2.1.jar:3.2.1]
at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:38) ~[mybatis-3.2.1.jar:3.2.1]
at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:49) ~[mybatis-3.2.1.jar:3.2.1]
at org.apache .ibatis.binding.MapperProxy.invoke(MapperProxy.java:42) ~[mybatis-3.2.1.jar:3.2.1]
at com.sun.proxy.$Proxy14.user_register_check(Unknown Source) ~[na:na]
說明:
上面這個錯誤,解釋的也很明顯,這不就是mapper和dao對映不上麼。
確實,這個方向沒有錯。正常,我會檢查,mapper的namespace、 dao,mapper 的方法名 等等這些 看看是不是這些細微的小問題。。
然後就是大量時間的花費,最後發現沒毛病!!! crazy? excuse me??
好了,不逗了,最後檢查一下maven的輸出目錄吧!也許根本就沒有mapper檔案,像這樣>>
專案和mapper有關的部分
輸出目錄 :
這就是問題,maven根本沒有把mapper輸出,所以pom.xml 加入如下
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.7</version>
<configuration>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8888</port>
<maxIdleTime>30000</maxIdleTime>
</connector>
</connectors>
<webAppSourceDirectory>${project.build.directory}/${pom.artifactId}-${pom.version}</webAppSourceDirectory>
<contextPath>/</contextPath>
</configuration>
</plugin>
</plugins>
<!-- 新增資源標籤 -->
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
ok ! 可以了 !