maven+ssm[報錯]Invalid bound statement (not found):找不到mapper文件標籤statement的id對應的方法

  • 首先查看以下路徑等配置是否一致:

mapper.xml的namespace要寫所映射接口的全稱類名。
mapper.xml中的每個statement的id要和接口方法的方法名相同
mapper.xml中定義的每個sql的parameterType要和接口方法的形參類型相同
mapper.xml中定義的每個sql的resultType要和接口方法的返回值的類型相同
mapper.xml要和對應的mapper接口在同一個包下
mapper.xml的命名規範遵守: 接口名+Mapper.xml

 

 

  • 然後看pom的build中是否有如下配置:如果沒有以下的配置就會找不到mapper文件

<build>    
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <!-- 此配置不可缺,否則mybatis的Mapper.xml將會丟失 -->
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>
            <!--指定資源的位置-->
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.yml</include>
                    <include>**/*.properties</include>
                </includes>
            </resource>
        </resources>
</build>

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章