配置文件属性未在POM中解析 - Maven 3.2.1

时间:2015-06-10 11:00:43

标签: java maven maven-3 maven-plugin

我的要求是拥有个人资料特定属性。所以,我在<profile>.properties中定义了src/main/resources/filters/,我想用它来填充application.properties文件。

POM的一部分:

<profiles>
        <profile>
            <id>local</id>
            <properties>
                <build.profile.id>local</build.profile.id>
            </properties>
            <activation>
                <property>
                    <name>env</name>
                    <value>local</value>
                </property>
            </activation>
        </profile>
        <profile>
            <id>prod</id>
            <properties>
                <build.profile.id>prod</build.profile.id>
            </properties>
            <activation>
                <property>
                    <name>env</name>
                    <value>prod</value>
                </property>
            </activation>
        </profile>
    </profiles>

    <build>
        <filters>
            <filter>src/main/resources/filters/${build.profile.id}.properties</filter>
        </filters>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>

Application.properties:

filter-path=${filter-path}

local.properties:

filter-path=C:\\Users\\username\\Documents\\filter-config.conf

问题是我在战争包装线上的POM中收到以下错误:

Multiple annotations found at this line:
    - Error loading property file 'C:\Users\username\workspace\xe-receiver\src\main\resources\filters\${build.profile.id}.properties' (org.apache.maven.plugins:maven-resources-plugin:
     2.6:testResources:default-testResources:process-test-resources)
    - Error loading property file 'C:\Users\username\workspace\xe-receiver\src\main\resources\filters\${build.profile.id}.properties' (org.apache.maven.plugins:maven-resources-plugin:
     2.6:resources:default-resources:process-resources)

任何人都可以请我解决这个问题吗?感谢。

0 个答案:

没有答案