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>

猜你喜欢

转载自blog.csdn.net/cleanblood/article/details/84872863
今日推荐