Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin

后端 未结 12 1323
感情败类
感情败类 2021-02-04 06:49

I got a maven spring project but when I try to run it, I can\'t... some idea about it...
The next is the Error Message:

BUILD FAILURE
-----------------------         


        
相关标签:
12条回答
  • 2021-02-04 07:01

    one thing that may cause this problem is that in your project in a POM file required java or maven version is set. you should find it... but how ? maybe you couldn't find any enforcer in your project like me ... (I had the same problem and I became confused because enforcer plugin was not defined in my projects POMs, so I couldn't find it).

    enforcer plugin is in your "effective pom" and you should check it. Effective pom is a configuration file made from super pom + project pom. maven use this configuration file to execute the relevant goal. It helps developers to specify minimum configuration detail in his/her pom.xml. Although configurations can be overridden easily.

    For showing your effective pom there are 2 ways: 1- use maven command, run this command :

     mvn help:effective-pom
    

    2- use your IDE : in Maven window right click on your project node and select show effective POM(it depends on your IDE).

    after you find what your forces are you can find it in your project and change it. for me, My effective POM had enforcer plugin which its requireMavenVersion rule for using Java was 1.8. so I changed my project JDK version to 1.8 and luckily the problem was solved.

    I hope this answer could help you.

    0 讨论(0)
  • 2021-02-04 07:01

    If you are using version 1.4.1 of maven-enforcer-plugin and it is resulting in this error then you need to use an older version of maven-enforcer-plugin. You can find the Maven dependency below :

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>1.3.1</version>
    </plugin>
    

    Other versions can be found from the link below.

    https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-enforcer-plugin

    Also, check your Maven version. If you are using maven 3.0.x then you need to use maven-enforcer-plugin 1.4.1.

    0 讨论(0)
  • 2021-02-04 07:05

    I faced the same issue and resolved it by fixing the pom versions. Below command didn't run properly on all the sub pom's which resulted in different pom versions. 'mvn versions:set -DnewVersion=${NEW_VERSION} versions:commit' Check whether all the moms have same version if there is dependent pom's.

    0 讨论(0)
  • 2021-02-04 07:08

    You should probably check if you have two different versions of same artifact somewhere. I faced it when I wanted to add new maven dependency while I already added it on a different dependent project with different versions.

    0 讨论(0)
  • 2021-02-04 07:12

    This worked for me.

    mvn clean
    mvn clean install
    
    0 讨论(0)
  • 2021-02-04 07:15

    You should solve the root cause of the issue, conflict between some of your dependecies, mvn/java version, there is a lot os possible reasons.

    But this is a workaround to build ignoring the error

    To skip enforcer (not always working)

    mvn clean install -Denforcer.skip=true
    

    To continue the build if error

    mvn clean install -Denforcer.fail=false
    
    0 讨论(0)
提交回复
热议问题