IDEA 使用junit 做单元测试遇到的问题

报错信息:Invalid bound statement (not found):  找不到绑定的mapper

解决步骤

看target 目录下是否存在mapper.xml 文件,如果不存在的话,应该是因为你的mapper.xml是放在java文件夹下,而不是resources目录下。这就需要在pom.xml文件下配置resources

<resources>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>
View Code

如果还是不行就看下 mapperLocations 的配置路径   mapperLocations="classpath:com/**/mapper/*.xml"

是不是使用了”  **  “符号表示,需要将他替换成具体的目录!!!!!!

posted @ 2020-06-03 15:58  达达的码蹄  阅读(807)  评论(0编辑  收藏  举报