IDEA中Maven项目target目录下缺少包及mapper.xml文件

  • Post author:
  • Post category:其他


学习笔记:

我的项目是Maven工程,SpringMVC+Spring+Mybatis,发现在tomcat启动时报mapper.xml文件找不到。

Caused by: java.lang.IllegalArgumentException: Could not resolve resource location pattern [classpath:com/java/activiti/mappers/*.xml]: class path resource [com/java/activiti/mappers/] cannot be resolved to URL because it does not exist
	at org.springframework.core.io.support.ResourceArrayPropertyEditor.setAsText(ResourceArrayPropertyEditor.java:140)
	at org.springframework.beans.TypeConverterDelegate.doConvertTextValue(TypeConverterDelegate.java:449)
	at org.springframework.beans.TypeConverterDelegate.doConvertValue(TypeConverterDelegate.java:422)
	at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:195)
	at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:461)
	... 62 more

我的工程目录是:

然后看到,我的target目录结构是:

在com.java.activiti下缺少了mapper包,那么怎么才能mapper包发布出来呢,原来IDEA并不会将src\main\java\目录下的配置文件(.xml)和资源文件(.properties)搬运到target目录下,解决办法是修改pom.xml文件,添加以下代码:

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

然后clean工程,重启tomcat,解决



版权声明:本文为liliuqing原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。