将文件替换为由mvn包生成的WAR文件



我有一个maven项目,我希望在使用clear packagemaven命令时替换源代码中的配置文件,并在WAR中用令人兴奋的文件替换它。我试过了,但替换只发生在提取的文件夹中,而不是WAR文件中这是我的pom.xml

<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>target/Project-xyz/classes/resources</outputDirectory>  
<resources>
<resource>
<directory>${basedir}/src/main/java/resources/customers</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>

经过多次试验,使用

org.apache.maven.plugins

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<executions>
<execution>
<id>default-war</id>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp/resources/customer1/css</directory>
<targetPath>resources/css</targetPath>
</resource>
</webResources>
</configuration>
</execution>
</executions>
</plugin>

最新更新