【问题标题】:Maven, using property from property file to read another property fileMaven,使用属性文件中的属性来读取另一个属性文件
【发布时间】:2013-11-20 10:18:53
【问题描述】:

我想从属性文件中读取属性,然后使用这个值来获取另一个属性文件的路径来读取它。

我使用properties-maven-plugin,但它似乎无法做到这一点,或者我使用不当。

我想要这样的东西:

                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>properties-maven-plugin</artifactId>
                    <version>1.0-alpha-2</version>
                    <executions>
                        <execution>
                            <phase>initialize</phase>
                            <goals>
                                <goal>read-project-properties</goal>
                            </goals>
                            <configuration>
                                <files>
                                    <file>${*value from another property file*}/prop.properties</file>
                                </files>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

【问题讨论】:

    标签: maven


    【解决方案1】:

    Maven 本身不允许在 pom.xml 中使用来自外部文件的属性——这就是你已经使用properties-maven-plugin 的原因。 你把自己置于一个先有蛋的情况下,插件需要先于自身运行。

    可行的办法是您将两个属性文件都放在文件列表中 - 运气好的话,这些都已解决。

    我的下一个尝试是添加插件两次(或两次执行)以加载第一个属性文件,然后让它在第二个文件上工作。

    【讨论】:

    • 我使用了两次执行,它工作正常。谢谢你的回答。
    猜你喜欢
    • 1970-01-01
    • 2016-09-08
    • 2013-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-31
    • 1970-01-01
    • 2015-11-19
    相关资源
    最近更新 更多