java - 如何告诉 eclipse 在不更改 pom.xml 的情况下不要验证 pom.xml?

标签 java eclipse maven m2eclipse jacoco

我的 pom.xml 很好,我可以毫无问题地进行 mvn clean 安装,但 eclipse 将其涂成红色并提示:

Description Resource    Path    Location    Type
Plugin execution not covered by lifecycle configuration: org.jacoco:jacoco-maven-plugin:0.5.10.201208310627:prepare-agent (execution: default, phase: initialize)   pom.xml /super-project  line 11 Maven Project Build Lifecycle Mapping Problem

我如何告诉 eclipse 忘记 pom.xml,换句话说,不要尝试编译它、验证它等,这样我的项目就不会出现错误,也不会被涂成红色?

最佳答案

我过去也遇到过类似的问题,eclipse 不喜欢 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-dependency-plugin
                                </artifactId>
                                <versionRange>
                                    [2.6,)
                                </versionRange>
                                <goals>
                                    <goal>
                                        copy-dependencies
                                    </goal>
                                </goals>
                            </pluginExecutionFilter>
                            <action>
                                <ignore />
                            </action>
                        </pluginExecution>
                    </pluginExecutions>
                </lifecycleMappingMetadata>
            </configuration>
        </plugin>
    </plugins>
</pluginManagement>

这很困惑,但也可以防止 future 的开发人员遇到同样的麻烦。

official m2e page如果您运行的是 4.2 Juno,有办法忽略它们

关于java - 如何告诉 eclipse 在不更改 pom.xml 的情况下不要验证 pom.xml?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14984068/

相关文章:

java - 在 Java 中加载 JSON : java. lang.ClassCastException : java. lang.Long 无法转换为 java.lang.Integer

java - 在 ubuntu 10.04 上安装 openjdk-7-jre - 包 openjdk-7-jre 没有安装候选

java - 从目录上传图像并设置为按钮

java - Maven 无法下载依赖项

java - kendo taglib jar 的 Maven 依赖项

java - 在jsp指令中

java - 针对不同环境的 Maven 构建

eclipse - java.io.IOException : Invalid argument at java. io.WinNTFileSystem.canonicalize0

java - 编写程序求三角形的长度 C

spring-boot - 是否可以从 Maven 多模块项目的父模块中的配置文件夹加载 Spring-Boot 属性?