IDEA+Maven:invalid bound statement (not found)解決辦法

王東昇KevinTech發表於2018-08-22

IDEA+Maven的SSM專案,遇到一個深坑invalid bound statement (not found),就是mapper檔案掃描不到!

各種除錯,各種找Bug,網上大多數人說是mapper配置檔案路徑問題,但我的沒錯啊,最後才發現這種說法:

原來是需要在pom.xml檔案中配置resource,不然mapper.xml檔案就會被漏掉!

pom.xml的<build>中配置了resource,bug消失了~

        <!-- 如果不新增此節點mybatis的mapper.xml檔案都會被漏掉。 -->
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>

 

相關文章