对于MAVEN项目,Eclipse会自动把项目srcmainjava目录下的配置文件(.xml)和资源文件(.properties)搬运到target目录下,而intellij idea默认是不会帮我们做这件事的。
解决办法:
在pom.xml文件中加入以下配置:
<build> <resources> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> <include>**/*.tld</include> <include>**/*.xls</include> <include>**/*.xlsx</include> </includes> </resource> <resource> <directory>src/main/java</directory> <includes> <include>**/*.properties</include> <include>**/*.tld</include> <include>**/*.xls</include> <include>**/*.xlsx</include> <include>**/*.xml</include> </includes> </resource> </resources> </build>
这段配置的意思就是把src/main/java和src/main/resources目录下所有的<include>里配置的相关文件都包含进去
同样,想包含其他什么文件,比如.txt文件,再加一个<include>标签类似的写法即可。
做了以上工作以后,再把项目“Reimport”(右键选中项目->Maven->Reimport)一下,启动服务器