java - Maven 编译器插件错误(maven-compiler-plugin :2. 5.1:testCompile)

标签 java maven

这是我在 pom.xml 文件中弹出的错误,我真的不知道为什么会发生这种情况

Plugin execution not covered by lifecycle configuration:
org.apache.maven.plugins:maven-compiler-plugin:2.5.1:testCompile
(execution: default-testCompile, phase: test-compile)

POM

    ....
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-eclipse-plugin</artifactId>
                    <version>2.9</version>
                    <configuration>
                        <additionalProjectnatures>
                            <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                        </additionalProjectnatures>
                        <additionalBuildcommands>
                            <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                        </additionalBuildcommands>
                        <downloadSources>true</downloadSources>
                        <downloadJavadocs>true</downloadJavadocs>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <configuration>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </plugin>
                <plugin>    **<--HERE!!**
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.5.1</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                        <compilerArgument>-Xlint:all</compilerArgument>
                        <showWarnings>true</showWarnings>
                        <showDeprecation>true</showDeprecation>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>1.2.1</version>
                    <configuration>
                        <mainClass>org.test.int1.Main</mainClass>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </project>

ALSO 我可以补充一点,我的工作区中有 3 个项目,每个项目都在 pom.xml 文件中显示相同的错误

解决方案

这对我有用。不太清楚为什么..

   ...
       <pluginManagement>
            <plugins>
                <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no 
                    influence on the Maven build itself. -->
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.apache.maven.plugins</groupId>
                                        <artifactId>maven-compiler-plugin</artifactId>
                                        <versionRange>[3.2,)</versionRange>
                                        <goals>
                                            <goal>compile</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>  
     ...

最佳答案

如果您使用的是 m2Eclipse(看起来像这样),请尝试将其添加到您的 POM 中。

<pluginManagement>
    <plugins>
        <!--This plugin's configuration is used to store Eclipse 
            m2e settings only. It has no influence on the Maven build itself. -->
        <plugin>
            <groupId>org.eclipse.m2e</groupId>
            <artifactId>lifecycle-mapping</artifactId>
            <version>1.0.0</version>
            <configuration>
                <lifecycleMappingMetadata>
                    <pluginExecutions>
                        <pluginExecution>
                            <pluginExecutionFilter>
                                <groupId>org.codehaus.mojo</groupId>
                                <artifactId>aspectj-maven-plugin</artifactId>
                                <versionRange>[1.0,)</versionRange>
                                <goals>
                                    <goal>test-compile</goal>
                                    <goal>compile</goal>
                                </goals>
                            </pluginExecutionFilter>
                            <action>
                                <execute />
                            </action>
                        </pluginExecution>
                    </pluginExecutions>
                </lifecycleMappingMetadata>
            </configuration>
        </plugin>
    </plugins>
</pluginManagement>

上官方site您可以找到更多答案。

编辑:
您是否更改了pluginExecutionFilter? 它应该包含您的插件信息。

<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>

然后更改目标以满足您的需要

关于java - Maven 编译器插件错误(maven-compiler-plugin :2. 5.1:testCompile),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33941195/

相关文章:

java - 在Java程序中访问Jenkins环境变量

java - Spring boot docker插件每次都需要删除镜像

c++ - 关于在Gradle中链接外部 native lib(opencv c++)

android - 使用 Gradle 从 Artifactory 访问依赖项

maven - 部署到 Heroku 时自定义 Maven 命令

java - java扫雷游戏中的Stackoverflow异常

java - 带 JMX 的 Datadog,datadog docker 镜像未安装 java

java - 如何从 JavaDB 读取数据

java - 在哪里可以找到可与 vlcj 2.1.0 配合使用的 "libvlc"的更新版本?

java - 如何检测 Active Directory 用户帐户的重命名或移动操作?