我有一個maven多模塊項目(model,service,util,webapp)。我在webapp項目的pom.xml中定義了一些配置文件。模塊化項目中的資源過濾
<profile>
<id>Dev</id>
<properties>
<db.driverClass>..</db.driverClass>
<db.connectionURL>..</db.connectionURL>
<db.username>..</db.username>
<db.password>..</db.password>
<pathFile>myFolder/myFirstPath/</pathFile>
</properties>
</profile>
<profile>
<id>Prod</id>
<properties>
<db.driverClass>..</db.driverClass>
<db.connectionURL>..</db.connectionURL>
<db.username>..</db.username>
<db.password>..</db.password>
<pathFile>myFolder/mySecondPath/</pathFile>
</properties>
</profile>
我想動態改變位於我的實用程序項目中的屬性路徑。 這是我的模塊化項目
|-- parent
`-- pom.xml
|-- model
| `-- pom.xml
|-- util
|--src
|--main
|--resources
|--props
props.properties
| `-- pom.xml
|-- webapp
` -- pom.xml
的骨架在UTIL項目的pom.xml我啓用了資源過濾
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
,最後我寫了
pathToChange = $ {pathFile}
在props.properties文件中。但是當我運行
命令mvn碼頭:運行-P開發
pathToChange屬性的值不會改變。 我在哪裏做錯了?
可以肯定的是,當您查看屬性是否更改時,您正在檢查目標目錄?當你說它沒有改變時,它有什麼價值? –
該值保持不變pathToChange = $ {pathFile} – Skizzo