[英]Maven resource filtering not working on Spring configuration XML file wiith tests
I am trying to add some filtering to the Spring
application context file, which resides in src/main/resources
folder but it's not working. 我正在尝试向Spring
应用程序上下文文件添加一些过滤,该文件位于src/main/resources
文件夹中,但无法正常工作。 I put my filter file in src/main/filters
我将过滤器文件放在src/main/filters
I've tried many solutions but none are working when i launch unit test through maven install or junit but if i skip test it's filtering it's working . 我尝试了许多解决方案,但是当我通过maven install或junit启动单元测试时,任何解决方案都无法正常工作,但是如果我跳过测试,它正在过滤工作。
I've modified the file .classPath
, I removed exclude
attribute from the file edit classpath solution then I read this article bug in maven-resources-plug who said that there is a bug in maven-resources-plugin so I updated the plugin to a newer version but it's still not working. 我已经修改了.classPath
文件,从文件编辑类路径解决方案中删除了exclude
属性,然后阅读了maven-resources-plug中的这篇文章错误,他说maven-resources-plugin中存在错误,因此我将插件更新为较新的版本,但仍无法正常工作。
My pom.xml : 我的pom.xml:
<build>
<finalName>core-impl</finalName>
<directory>target</directory>
<sourceDirectory>src/main/java</sourceDirectory>
<outputDirectory>target/classes</outputDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<testOutputDirectory>target/test-classes</testOutputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<filters>
<filter>src/main/filters/filter.properties</filter>
</filters>
</build>
i tried this solution and it's working . 我尝试了这种解决方案,它正在工作。
<execution>
<id>default-resources</id>
<phase>process-resources</phase>
<goals>
<goal>resources</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<filters>
<filter>${basedir}/src/main/filters/filter.properties</filter>
</filters>
</configuration>
</execution>
<execution>
<id>default-testResources</id>
<phase>process-test-resources</phase>
<goals>
<goal>resources</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<filters>
<filter>${basedir}/src/test/filters/filter.properties</filter>
</filters>
</configuration>
</execution>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<testResources>
<testResource>
<filtering>true</filtering>
<directory>src/test/resources</directory>
</testResource>
</testResources>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.