加载属性文件Maven时出错

时间:2014-05-05 16:35:21

标签: java maven maven-resources-plugin

当我尝试从pom.xml加载过滤器文件时,我从eclipse标记中得到此错误。 它会显示以下信息。

 Error loading property file 'src/main/filters/filter.properties' (org.apache.maven.plugins:maven-resources-plugin:2.6:resources:default-resources:process-resources)

的pom.xml:

 <execution>
        <id>default-resources</id>
            <phase>process-resources</phase>
        <goals>
            <goal>resources</goal>
        </goals>
        <configuration>
            <resources>
                <resource>
                    <directory>src/main/resources</directory>
                    <filtering>true</filtering>
                </resource>
            </resources>
            <filters>
                <filter>src/main/filters/filter.properties</filter>
            </filters>
        </configuration>
    </execution>

是个错误吗?

1 个答案:

答案 0 :(得分:6)

解决方案是${basedir}/src/main/filters/filter.properties而不是src/main/filters/filter.properties

<execution>
        <id>default-resources</id>
            <phase>process-resources</phase>
        <goals>
            <goal>resources</goal>
        </goals>
        <configuration>
            <resources>
                <resource>
                    <directory>src/main/resources</directory>
                    <filtering>true</filtering>
                </resource>
            </resources>
            <filters>
                <filter>${basedir}/src/main/filters/filter.properties</filter>
            </filters>
        </configuration>
    </execution>