【发布时间】:2012-01-13 06:41:19
【问题描述】:
我正在尝试获取一些变量属性值并使用 Maven 配置文件来获得正确的输出。我已经为我的休眠 xml、log4j.properties 完成了这个并且没有问题。
所以它在项目#1 中对我有用,我在 /src/main/resources 下有一堆文件。我在maven中设置属性和资源过滤如下:
<properties>
<log.level>DEBUG</log.level>
</properties>
<profiles>
<profile>
<id>production</id>
<properties>
<log.level>INFO</log.level>
</properties>
</profile>
</profiles>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
以上操作没有问题。 但是,在我的 Project#2 中-我有一些具有可变属性的文件,但它们位于 /src/main/webapp/WEB-INF 下-我执行与上面相同的操作,除了指向 WEB-INF 的目录它不起作用。我在项目 #2 上尝试了将文件放在 /src/main/resources 下并且它有效。
所以在我看来,当文件位于 /src/main/webapp/WEB-INF 下时资源过滤有问题,但我需要该文件在那里,以便在生成战争时进入 WEB-INF 文件夹。
有没有人指点一下如何做到这一点?
以下是 pom.xml 中不起作用的片段(完全忽略了资源过滤)
<properties>
<wsdl.url>http://stage/wsdl-url</wsdl.url>
</properties>
<profiles>
<profile>
<id>production</id>
<properties>
<wsdl.url>http://prod/wsdl-url</wsdl.url>
</properties>
</profile>
</profiles>
<build>
<resources>
<resource>
<directory>src/main/webapp/WEB-INF</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
【问题讨论】:
标签: maven maven-profiles