2017-05-22 42 views
0

假設在我的spring項目的pom.xml中有一個屬性customProp。 2.4.snap如何在spring項目中更新終端中的pom.xml屬性?

當我跑我的項目,我可以像下面

mvn clean install -DcustomProp=newValue 

它的工作以及更新它的值。它用newValue更新customProp的值。
但我想連接newValue與以前的值customProp。因此customProp的值將是2.4.snapnewValue。 我該怎麼做?

此外,是否有可能用newValue替換snap,以使customProp的值爲2.4.newValue

+3

'-DcustomProp1 =值-DcustomProp2 = newValue'並在pom.xml' $ {customProp1} $ {} customProp2' –

回答

1
<properties> 
    <customProp>snap</customProp> 
</properties> 

<version>2.4.${customProp}</version> 

這可能在您的情況嗎?當然,在我使用<version>的地方使用正確的標籤。


接近,這可能是更像是最好的辦法:

<properties> 
    <customPropPrefix>2.4.</customPropPrefix> 
    <customProp>snap</customProp> 
</properties> 

<version>${customPropPrefix}${customProp}</version> 

現在,您可以同時指定-DcustomPropPrefix=2.4.-DcustomProp=newValue

0

而不是建立和強制清潔您的Maven項目,將確保更新您的Maven項目enter image description here

+0

儘量不要在這裏放置任何外部鏈接;對於這種答案,你可以很容易地解釋這裏的步驟,因爲描述起來並不複雜。如果你確實需要一張圖片作爲你的解釋,建議把圖片放在答案中,而不是使用外部鏈接。 –

相關問題