作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
假设我从某处获得了一个属性文件,它具有以下定义:
dog=POODLE
mvn clean install -animal=dog
"POODLE"
不知道要查找的属性是什么(我还不知道我正在查找“狗”,但只知道我正在查找“动物”)。
${animal}
它将被替换为
dog
,但后来我需要查一下。
${${animal}}
最佳答案
如果你使用 -Danimal=${dog}
它应该可以工作.这是我的例子
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>nested-property</groupId>
<artifactId>nested-property</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<dog>POODLE</dog>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.soebes.maven.plugins</groupId>
<artifactId>maven-echo-plugin</artifactId>
<version>0.1</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>echo</goal>
</goals>
</execution>
</executions>
<configuration>
<echos>
<echo>Animal: ${animal}</echo>
</echos>
</configuration>
</plugin>
</plugins>
</build>
</project>
mvn -Danimal=${dog} install
[INFO] --- maven-echo-plugin:0.1:echo (default) @ nested-property ---
[INFO] Animal: POODLE
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
关于maven - 如何在另一个属性中引用 Maven 属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15074634/
我是一名优秀的程序员,十分优秀!