Could not resolve resource location pattern [classpath:com/macw/mapper/*.xml]:Spring項目報錯找不到mapper文件

*java.lang.IllegalArgumentException: Could not resolve resource location pattern 
[classpath:com/macw/mapper/*.xml]: class path resource [com/macw/mapper/] cannot be 
resolved to URL because it does not exist* 

SpringMVC項目報錯找不到Mapper文件,

啊啊啊這個問題昨天頭疼了我好大一會,我mapper文件確實存在啊,並且路徑也沒有問題啊,可是就是一編譯就報錯。

報錯信息如下圖所示:
springMVC項目報錯找不到mapper文件
再來看看我的目錄結構:
在這裏插入圖片描述
確實沒問題是不是,
不甘心,今天又重新看了一遍項目,依舊是報錯,抱着試試看的態度我找了找class文件,
哎~,發現問題了。

看下target目錄:
在這裏插入圖片描述
果然就是沒有mapper包啊,這就很沒明確了,

說明xml文件沒有被maven打包到target下面.在pom.xml的< build>標籤中加入:

<resources>
   <resource>
    <directory>src/main/java</directory>
    <includes>
       <include>**/*.xml</include>
    </includes>
    <filtering>true</filtering>
   </resource>
</resources>

ok,大功告成!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章