0
我有dev/XYZ.properties文件,我正在使用maven -P dev安裝構建一個jar文件。我怎麼能放在child.jar屬性文件/ META-INF/XYZ.properties文件Maven Profiles Jar問題
我有dev/XYZ.properties文件,我正在使用maven -P dev安裝構建一個jar文件。我怎麼能放在child.jar屬性文件/ META-INF/XYZ.properties文件Maven Profiles Jar問題
你必須執行maven-resources-plugin:copy-resources
目標,爲您的個人資料dev
並用適當的階段將其綁定(process-resources
似乎是最好的階段,我)。下面是如何定義您的個人資料dev
:
<profile>
<id>dev</id>
...
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/classes/META-INF</outputDirectory>
<resources>
<resource>
<directory>${basedir}/dev</directory>
<includes>
<include>XYZ.properties</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
感謝您的代碼,我可以部署特性基於輪廓子級別文件。如果我運行測試配置文件,則按預期部署child-test.jar。現在,如果我想從父項目構建一個war文件,如果我想運行一個dev配置文件,我得到父-dev.war,jar中的child-jat仍然是child-test.jar。這是如何預期的。如果我想在我的戰爭和jar文件中使用所有開發者配置文件,那麼我需要這樣做,能否請您告知 – user665837 2013-03-25 15:05:47
不用客氣。不要猶豫,upvote並接受我的答案...這就是它在stackoverflow上的方式(http://stackoverflow.com/about) – ben75 2013-03-25 15:09:23
如果我在父項目上運行開發配置文件,我沒有得到開發配置文件的子開發配置文件,如果我的eclipse中的目標文件夾不是空的,是否有任何方式在maven我可以克服這個問題,即,如果我在父項目上運行開發配置文件,我所有的父項目和子項目都應該獲取基於配置文件的值在這種情況下運行示例dev。 – user665837 2013-03-25 15:14:52