我有3个不同的简档的Maven应用,下面在Maven中替换文件的正确方法是什么?
<profiles>
<profile>
<id>dev</id>
<properties>
<profileVersion>DEV</profileVersion>
<webXmlFolder>${id}</webXmlFolder>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<profileVersion>1.0.0-RC1</profileVersion>
<webXmlFolder>${id}</webXmlFolder>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<profileVersion>1.0.0-Final</profileVersion>
<webXmlFolder>${id}</webXmlFolder>
</properties>
</profile>
</profiles>
指定我有Maven的结构是这样的:
的src /主/配置/默认/ WEB-INF/web.xml中
的src /主/配置的/ dev/WEB-INF/web.xml中
的src /主/配置/测试/ WEB-INF/web.xml中
的src/main /配置/生产/ WEB-INF/web.xml中
的src /主/ web应用/ WEB-INF/
我的任务是要设置指定的web.xml中为web应用/ WEB- INF在构建时取决于指定的配置文件。如果未指定配置文件,则web.xml将从默认文件夹复制。
我有插件,但它不工作。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>copy-prod-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>${project.build.outputDirectory}/classes/WEB-INF</outputDirectory>
<resources>
<resource>
<directory>src/main/config/${webXmlfolder}/WEB-INF</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
任何想法?我花了很多时间处理这个问题,现在我很困惑。
所有定义的配置文件依赖于$ {id}属性,它是否在POM的其余部分中定义? –
我的错误是,$ {id}占位符值是定义的应用程序的全名,例如[groupId:artifactId:version]而不是简档ID名称。 :) –