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

javamavennetbeansspring

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
------------------------------------------------------------------------
Total time: 4.532s
Finished at: Wed Jul 26 16:04:06 COT 2017
Final Memory: 17M/196M
------------------------------------------------------------------------
Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.4.1:enforce
(enforce-versions) on project SIMI: Some Enforcer rules have failed. Look above for
specific messages explaining why the rule failed. -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.

Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Best Answer

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.

Related Topic