相关链接:http://maven.apache.org/plugins/maven-resources-plugin/examples/resource-directory.html
maven打包时,默认的会寻找项目中的 src/main/resources 寻找资源文件,打包到classes下
但是,有时我们会将资源文件放置到别的目录中,此时只需要配置如下
<project>
...
<build>
...
<resources>
<resource>
<directory>[your folder here]</directory>
</resource>
</resources>
...
</build>
...
</project>
其中:
<!-- 描述存放资源的目录,该路径相对POM路径-->
<directory></directory>
如果maven项目中配置文件在jar项目中,且希望在打包时将配置文件打包到war下的classes中,只需要使用相对路径指向jar项目中的配置文件目录即可。
特别的:
resources中多个资源目录配置时,如果不同目录有相同的资源文件名时,先配置的resource中的文件将会覆盖掉后配置的文件。