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"

是不是使用了”  **  “符號表示,需要將他替換成具體的目錄!!!!!!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM