【发布时间】:2012-07-02 16:11:59
【问题描述】:
关于这个问题有很好的 SO question and answers,但这些选项对我不起作用。
我想将变量传递给应用上下文:
<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>
我试过this option(这有点奇怪),但没有结果。比我添加了这个插件:
<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 重复这些步骤,但没有帮助。有人可以提供一个工作代码 sn-p 或告诉我我在这里想念什么吗?提前致谢。
更新:我错了,properties-maven-plugin 工作正常。
【问题讨论】:
-
src/main/resources或src/main/java下的 applicationContext.xml 到底在哪里? -
@yorkw 在 src/main/resources 下。没事吧?
标签: maven properties settings