java - 如何在maven、Spring-boot中解决 "Conflicting lifecycle mapping"

标签 java spring maven spring-boot

我面临的问题是每次我创建一个新的 Spring Boot 项目时,我都会在 pom.xml 中收到以下错误(旁边)

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

基本的 pom.xml 是这样的:

   <?xml version="1.0" encoding="UTF-8"?>
<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>com.emi</groupId>
<artifactId>catalogue</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>MyCatalogue</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository --> 
</parent>


<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
</dependencies>

<build>

    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>

    </plugins>

</build>

我尝试删除并重新创建存储库,但同样的错误仍然存​​在。我也尝试过 java 7 但没有解决方案。你能帮忙吗?

最佳答案

在你的 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>

或者将相同的内容粘贴到 eclipse/plugins/org.eclipse.m2e.lifecyclemapping.defaults_1.2.0.20120903-1050.jar/lifecycle-mapping-metadata.xml 中或在那里查找重复项。

关于java - 如何在maven、Spring-boot中解决 "Conflicting lifecycle mapping",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33771094/

相关文章:

Spring事务——检测回滚和提交

java - 在 Weblogic 12c (12.2.1.3) 中使用提供的 jax-rs 2.0 和 Jersey 2.1x

java - Java中添加pom.xml依赖后Maven依赖不存在?

java - 无法启动 Activity ComponentInfo : Error inflating class android. support.design.widget.CoordinatorLayout

java - 如何使用 AspectJ 过滤方法的返回值?

java - 我的 isEmpty 方法不起作用,我不知道为什么

java - 具有本地文件依赖的Maven项目构建错误501

5000~ 用户的 Java Web 应用程序

java - 无法在spring + maven + tomcat中启动配置文件

spring - .com 电子邮件地址的获取请求失败,因为 Spring 将其解释为扩展