如何在maven中进行简单的资源过滤?

时间:2014-09-01 10:06:08

标签: java hibernate maven jenkins

我正在尝试按照指南解释如何进行资源过滤。我有一个hibernate属性文件,它现在具有以下属性;

    <!-- db connection properties -->
    <property name="hibernate.connection.url">${hibernate.connection.url}</property>
    <property name="hibernate.connection.username">${hibernate.connection.username}</property>
    <property name="hibernate.connection.password">${hibernate.connection.password}</property>

我的maven pom有以下个人资料;

<profiles>
    <profile>
        <id>DEV</id>
        <properties>
            <hibernate.connection.url>devurl:port</hibernate.connection.url>
            <hibernate.connection.username>user</hibernate.connection.username>
            <hibernate.connection.password>password</hibernate.connection.password>
        </properties>
    </profile>
    <profile>
        <id>PROD</id>
        <properties>
            <hibernate.connection.url>produrl</hibernate.connection.url>
            <hibernate.connection.username>user</hibernate.connection.username>
            <hibernate.connection.password>pass</hibernate.connection.password>
        </properties>
    </profile>
</profiles>

我在jenkins中的maven build url在更改之前看起来如下;

clean package org.jacoco:jacoco-maven-plugin:prepare-agent install -Dmaven.test.failure.ignore=true

我修改过的内容如下:

clean package -P DEV org.jacoco:jacoco-maven-plugin:prepare-agent install -Dmaven.test.failure.ignore=true

好像我已经按照指南中的所有内容进行了操作,所以我上面所做的事情必须是不正确的,因为当我进行构建时,我会收到大量错误,例如java.lang.UnsupportedOperationException: The application must supply JDBC connections。有人能够看到我做错了吗?

由于

1 个答案:

答案 0 :(得分:0)

我没有将xml文件包含在pom.xml

中的过滤器中
<resource>
            <directory>resources</directory>
            <filtering>true</filtering>
            <includes>
                <include>**/*.p12</include>
                <include>**/*.properties</include>
                <include>**/*.xml</include>
            </includes>
        </resource>