この問題については素晴らしいSOの質問と回答がありますが、これらのオプションは私には機能しませんでした。
変数をアプリコンテキストに渡したい:
<bean class="blah.blah.Blah" id="blah">
<property name="first" value="${first.property}"/>
<property name="second" value="${second.property}"/>
</bean>
Mavenのsettings.xml
ファイルには次のものがあります。
<profiles>
<profile>
<id>profileId</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<first.property>first value</first.property>
<second.property>second value</second.property>
</properties>
このオプションを試しましたが(少し奇妙です)、結果は得られませんでした。このプラグインを追加したよりも:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>write-project-properties</goal>
</goals>
<configuration>
<outputFile>
src/main/resources/maven.properties
</outputFile>
</configuration>
</execution>
</executions>
</plugin>
maven.properties
その後、プロジェクトにはファイルがありませんでした。空のファイルを作成した場合、何も表示されませんでした。そして、私はこれらのステップをで繰り返してみましたが-PprofileId
、役に立ちませんでした。誰かが実用的なコードスニペットを提供するか、ここで私が見逃していることを教えてもらえますか?前もって感謝します。
更新:私は間違っていました、うまくいきproperties-maven-plugin
ます。