Maven配置文件属性不是“覆盖”属性。 [英] Maven profile properties are not "overriding"

查看:1089
本文介绍了Maven配置文件属性不是“覆盖”属性。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Maven多模块项目,具有以下结构:

I have Maven multi-module project with such structure:


parent-pom-project

parent-pom-project

- module1

-- module1

- module2

-- module2

在parent-pom-project中我有这样的pom.xml

At the parent-pom-project I have such pom.xml

    <modules>
        <module>module1</module>
    </modules>
...
    <profiles>
        <profile>
           <id>local</id>
           <properties>
               <prop>local_prop</prop>
           </properties>
        </profile>
        <profile>
           <id>test</id>
           <modules>
                <module>module2</module>
           </modules>
           <properties>
               <prop>test_prop</prop>
           </properties>
        </profile>
    </profiles>

在所有pom.xml文件中我都有这样的标记:

At all pom.xml files I have such tag:

<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
        <resource>
            <directory>src/test/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
</build>

resource 目录中的module1和module2我有包含此类文本的属性文件:

At module1 and module2 in resource directory I have properties files with such text:

prop=${prop}

问题在于


mvn clean install

mvn clean install


mvn clean install -Ptest

mvn clean install -Ptest

甚至


mvn clean install -P test

mvn clean install -P test

我得到


prop = local_prop

prop=local_prop

如果构建模块2的用户测试配置文件也已构建,但属性是从本地配置文件中使用的。
我使用Maven 3.0.3。
有人有任何想法吗?

If I user test profile for build module2 is also builded, but properties are used from local profile. I use Maven 3.0.3. Anybody have any ideas?

推荐答案

我解决了为eclipse卸载当前maven插件的问题并使用了另一个。
现在我用这个:
- Maven集成: http://m2eclipse.sonatype .org / sites / m2e
- WTP的Maven集成: http: //m2eclipse.sonatype.org/sites/m2e-extras/

I resolve problem uninstalling current maven plugin for eclipse and use another one. Now I use this ones: - Maven Integration: http://m2eclipse.sonatype.org/sites/m2e - Maven Integration for WTP: http://m2eclipse.sonatype.org/sites/m2e-extras/

早期我使用的是 http://download.eclipse.org/technology/m2e/releases/ 。我无法解释这种行为,但可能是插件改变了一些配置。

Early I was using this one http://download.eclipse.org/technology/m2e/releases/. I cannot explain such behavior but may be some configuration was changed by plugin.

这篇关于Maven配置文件属性不是“覆盖”属性。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆