Eclipse + maven : profile ignored

三世轮回 提交于 2019-12-11 14:24:48

问题


Here is my pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.heliosophiclabs</groupId>
<artifactId>artifactId</artifactId>
<version>0.0.1-SNAPSHOT</version>

<profiles>
    <profile>
        <id>local</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <serverAddr>localhost</serverAddr>
        </properties>
    </profile>
    <profile>
        <id>prod</id>
        <properties>
            <serverAddr>heliosophiclabs.com</serverAddr>
        </properties>
    </profile>
</profiles>

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

I have a config.properties file in src/main/resources, which looks like this:

serverIp=${serverAddr}

and then I do:

mvn clean resources:resources -Pprod

Note that the profile is specified here as "prod", and yet, no matter how I insist, the config.properties file looks like this after the above command line:

serverIp=localhost

whereas it should be:

serverIp=heliosophiclabs.com

If I specify a non-existent profile in this command line, then maven gives me an error, so it's definitely doing something.

Please... what am I doing wrong here??

EDIT:

As requested, the output of "mvn -X -Pprod install" is available here, since it's far too big to post here.

And here is exactly what I see:

C:\Users\Marc\workspace_mars_2\entourage>mvn -X -Pprod install > mvn.out
C:\Users\Marc\workspace_mars_2\entourage>more target\classes\config.properties
serverAddr=localhost

In entourage-0.0.1-SNAPSHOT.jar, config.properties is at the root, and its contents are the same as above (i.e., localhost).

I'm not making stuff this up!


回答1:


After much discussion, it finally turned out that the issue was with the use of the "refresh using native hooks or polling" option ( preferences > general > workspace > refresh using native hooks ). Unchecking this option resolves the problem.

Bug report filed with Eclipse Foundation. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=462027



来源:https://stackoverflow.com/questions/28861267/eclipse-maven-profile-ignored

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!