在调用Mapper层方法时报错:Invalid bound statement (not found)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u011099093/article/details/86511574

今天在一个正常的springmvc项目中,调用方法传递至service层时报错:Invalid bound statement (not found),然后是一个方法没有找到。刚开始以为是参数类型的问题,Controller和Service层都是int型,Mapper层时Integer型,修改了之后还是依旧报错。

后来请教同事发现可能是pom.xml中缺少一个配置来让classpath中src/main/java下*.xml文件生效,查看target下对应mapper类路径下,果然没有发现.xml文件,于是添加了以下配置到pom.xml中,问题解决:

<build>
    <resources>
             <resource>
                <targetPath>${project.build.directory}/classes</targetPath>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/*.xml</include>
                    <include>**/*.properties</include>
                </includes>
            </resource>
            <resource>
                <targetPath>${project.build.directory}/classes</targetPath>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>
    </resources>
</build>

于是搜索了下这个配置:https://www.cnblogs.com/gossip/p/6060840.html,果然是让src/main/java下的.xml文件打包到target中。

猜你喜欢

转载自blog.csdn.net/u011099093/article/details/86511574