如果你使用它应该可以工作-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] ------------------------------------------------------------------------