一般来说,运行maven项目时会自动导出一个target包,java包和resource包默认生成路径都是在class下(这个路径为classpath)
maven由于他的约定大于配置,我们之后可以能遇到我们写的配置文件,无法被导出或者生效的问题,如:在java目录下,建立一个aa.properties文件,运行时target未生成对应的文件
解决方案:在当前模块下的porm.xml中加入下面代码
<!--在build中配置resources,来防止我们资源导出失败的问题-->
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>