2012-04-02 31 views
3

在我們的web.xml中,只有一個片段只用於開發,當應用程序部署到生產環境時,它不能存在。當使用生產配置文件調用Maven時,我想使用Configuration Processor Plugin刪除這個片段。Maven - 配置處理器插件生成的包web.xml

轉換本身很簡單,但是將生成的web.xml打包到WAR文件的最佳方式是什麼?我將轉換後的web.xml輸出到目錄target/generated-sources。 當生產配置文件處於活動狀態時,我希望Maven使用此web.xml而不是src目錄中的一個。如果此配置文件未激活,則應使用標準位置。

回答

3

我想創建一個屬性,也就是說,webXml.path和配置Maven方式如下:

<properties> 
    <webXml.path>src/main/webapp/WEB-INF/web.xml</webXml.path> 
</properties 
... 
<build> 
    <plugins> 
    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-war-plugin</artifactId> 
     <configuration> 
     <webXml>${webXml.path}</webXml> 
     </configuration> 
    </plugin> 
    </plugins> 
</build> 
... 
<profiles> 
    <profile> 
    <id>prod</id> 
    <properties> 
     <webXml.path>target/generated-sources/web.xml</webXml.path> 
    </properties> 
    </profile> 
</profiles>