maven修改默认配置文件位置,防止资源导出失败问题
maven的核心是约定大于配置,所以可能出现配置文件没有生效
解决方法:在pom.xml中配置resources
<!--在build中配置resources, 来防止我们资源导出失败问题-->
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
测试
maven项目约定properties文件放在resources文件下
在maven项目的java目录下的servlet包中创建一个abc.properties,测试发现编译文件中没有此文件
在pom.xml中配置
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
重新编译后
资源成功导出