我正在嘗試使用文件過濾器來過濾由maven-ear-plugin
生成的application.xml
文件。我的項目結構是Maven的標準。是否可以使用文件過濾器過濾生成的Maven EAR插件application.xml?
這裏是我的POM文件:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test-filter</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>ear</packaging>
<properties>
<prop1>xyz</prop1>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10.1</version>
<configuration>
<version>6</version>
<env-entries>
<env-entry>
<env-entry-name>env1</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>${prop1}</env-entry-value>
</env-entry>
</env-entries>
</configuration>
</plugin>
</plugins>
</build>
</project>
了這裏的一切工作正常。該插件生成一個application.xml
文件,其中包含env1
條目和插值xyz
。
問題是,當我移動Maven的財產prop1
到屬性文件和配置過濾器:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test-filter</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>ear</packaging>
<build>
<filters>
<filter>src/main/filters/filter.properties</filter>
</filters>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10.1</version>
<configuration>
<version>6</version>
<env-entries>
<env-entry>
<env-entry-name>env1</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>${prop1}</env-entry-value>
</env-entry>
</env-entries>
</configuration>
</plugin>
</plugins>
</build>
</project>
對於我的filters
功能的理解,就相當於爲特性,但使用一個單獨的文件。儘管如此,生成的application.xml
包含條目env1
而沒有插入${prop1}
。
當然的文件src/main/filters/filter.properties
存在幷包含:
prop1=abc
有什麼我失蹤?
該解決方案的屬性插件綁定到'initialize'階段。謝謝! –