我想要做的是以某種方式根據所使用的Maven配置文件替換屬性文件中resources.location的值。這甚至有可能嗎?
是的。激活資源過濾並定義要在每個配置文件中替換的值。
在你ApplicationResources.properties
,聲明令牌替換這樣的:
resources.location=${your.location}
在你的POM,加<filtering>
標籤爲適當<resource>
並將其設置爲true這樣的:
<project>
...
<build>
...
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
...
</resources>
...
</build>
...
</project>
然後,在每個配置文件內的<properties>
元素內添加一個<your.location>
元素:
<project>
...
<profiles>
<profile>
<id>my-profile</id>
...
<properties>
<your.location>/home/username/resources</your.location>
</properties>
...
</profile>
...
</profiles>
</project>
關於過濾資源here和here的更多信息。
@Pascal Thivent謝謝。這是一個很好的解釋 – 2010-02-25 17:06:53
+1我第二個:D – ant 2010-02-25 23:10:05