【发布时间】:2018-03-17 07:48:28
【问题描述】:
我有一个要清理的 Java Maven Web 应用程序项目。在我的pom.xml 的<build> 部分,我有以下内容:
<build>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
</resource>
</resources>
<filters>
<filter>profiles/${build.profile.id}.profile.properties</filter>
</filters>
[...other properties...]
</build>
在我的项目中,我的 Mac 上是/Users/anthony/workspace/my-project/,我有src/main/resources/profiles/我有local.profile.properties 和qa.profile.properties。
然后,在我的 pom 中的 maven 配置文件中,我将 ${build.profile.id} 定义如下:
<profile>
<id>local</id>
[...stuff...]
<properties>
<build.profile.id>local</build.profile.id> <!-- or qa -->
[...stuff...]
</properties>
</properties>
当我在控制台中运行 $ mvn clean install -Plocal 时,我收到以下错误:
Failed to execute goal ... on project my-project: Error loading property file '/Users/anthony/workspace/my-project/profiles/local.profile.properties'.
Maven 似乎无法识别我的过滤配置文件属性文件的资源目录。这仅在我明确放置属性文件的整个路径时才有效,如下所示:
<filters>
<filter>src/main/resources/profiles/${build.profile.id}.profile.properties</filter>
</filters>
有没有办法让我不必明确声明src/main/resources?我认为我声明资源目录的目的是我可以使用它,尤其是声明过滤。
【问题讨论】:
标签: java maven filter properties profile