如果在maven的pom.xml文件中,想像ant那樣引用外部的properties配置文件,可以通過兩種方式解決:
1.如果需要引用外部propertiest文件中的屬性值,需要在pom.xml中添加對外部文件的引用。例如,創建一個外部資源文件pom.properties:
properties-maven-plugin 使用方法可以看插件的官方地址:http://mojo.codehaus.org/properties-maven-plugin/
1.如果需要引用外部propertiest文件中的屬性值,需要在pom.xml中添加對外部文件的引用。例如,創建一個外部資源文件pom.properties:
# filter.properties
my.filter.value=hello!
<build>
<filters>
<filter>${baseDir}/pom.properties</filter>
</filters>
</build>
不過這種方式要啟動資源過濾,并設置好對應的文件夾才行,相對較麻煩。 2.使用插件:
maven-properties-plugin 使用方法可以看插件的官方地址:http://haroon.sis.utoronto.ca/zarar/properties-maven-plugin/index.html
properties-maven-plugin 使用方法可以看插件的官方地址:http://mojo.codehaus.org/properties-maven-plugin/