【问题标题】:maven super pom's profile properties inheritance at child pomsmaven super pom 在子 pom 中的配置文件属性继承
【发布时间】:2011-11-26 03:38:11
【问题描述】:

在我的项目中有 2 个配置文件,每个配置文件都有一个属性。 但是我不能在孩子的资源中使用主人的属性。

这里描述的很清楚,但是好像只有一个pom文件,并且那里显示的示例不是多模块maven项目。

我想要做的就是在 spring 级别使用这个属性,比如更改属性文件的位置。

 <profile>
        <id>p1</id>
        <properties>
            <properties.location>file:/apps-core1.properties</properties.location>
        </properties>
    </profile>
 <profile>

 <profile>
        <id>p2</id>
        <properties>
            <properties.location>file:/apps-core2.properties</properties.location>
        </properties>
    </profile>
 <profile>

我想在我拥有的每个 pom 文件中使用“properties.location”,无论是主资源还是测试资源。

这里是spring的用法

<context:property-placeholder location="\${properties.location}" />

【问题讨论】:

    标签: spring maven properties profile


    【解决方案1】:

    我让它与一个多模块项目一起工作:

    • 带有&lt;modules /&gt; 配置和您的个人资料的父pom
    • 具有以下配置的模块 pom

      <build>
         <resources>
            <resource>
               <directory>src/main/resources</directory>
               <filtering>true</filtering>
               <includes>
                  <include>**/*.xml</include>
               </includes>                
            </resource>
         </resources>
      </build>
      

    maven resources and filtering

    【讨论】:

    • 我已经为测试资源添加了这些配置和相同的配置。现在它适用于每个模块。
    • @Melih 你应该添加到
    猜你喜欢
    • 1970-01-01
    • 2014-07-22
    • 2019-06-07
    • 2012-12-22
    • 2012-03-17
    • 2018-08-24
    • 1970-01-01
    • 2018-08-09
    • 1970-01-01
    相关资源
    最近更新 更多