如何在Eclipse中显示maven属性?

如何在Eclipse中显示maven属性?,eclipse,maven,ant,m2e,maven-antrun-plugin,Eclipse,Maven,Ant,M2e,Maven Antrun Plugin,如何在Eclipse中显示maven属性 以下基于antrun插件的pom不起作用: <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"&

如何在Eclipse中显示maven属性

以下基于antrun插件的pom不起作用:

<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>Test_DisplayMavenVariables</groupId>
    <artifactId>Test_DisplayMavenVariables</artifactId>
    <version>0.0.1-SNAPSHOT</version>


    <properties>
        <testproperty>This is a test property</testproperty>
    </properties>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>1.1</version>
                    <executions>
                        <execution>
                            <phase>validate</phase>
                            <goals>
                                <goal>run</goal>
                            </goals>
                            <configuration>
                                <tasks>
                                    <echo>Displaying value of 'testproperty' property</echo>
                                    <echo>[testproperty] ${testproperty}</echo>
                                </tasks>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

</project>

您已将
antrun
定义放入
pluginManagement
块中

pluginManagement
的意思是:“如果有人使用这个插件,他将按以下方式操作…”


在您的示例中,没有人使用插件,因为没有正常的插件定义。从pom中删除
,它就会工作。

您尝试过这个吗?如果我删除
pluginManagement
,那么我会出现错误“生命周期配置未涵盖的插件执行:org.apache.maven.plugins:maven-antrun-Plugin:1.1:run(执行:默认,阶段:验证)”,我在这里发现了这两个独立的问题。您的属性应该正确显示。顺便说一句:你链接的公认答案是错误的。安德鲁·怀特的第二个答案是正确的。通过使用提供的快速修复,您可以很容易地实现这一点。
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Test_DisplayMavenVariables 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.110s
[INFO] Finished at: Sun Mar 23 15:22:00 MSK 2014
[INFO] Final Memory: 4M/183M
[INFO] ------------------------------------------------------------------------