*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文件確實存在啊,並且路徑也沒有問題啊,可是就是一編譯就報錯。
報錯信息如下圖所示:
再來看看我的目錄結構:
確實沒問題是不是,
不甘心,今天又重新看了一遍項目,依舊是報錯,抱着試試看的態度我找了找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,大功告成!