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
-----------------------
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.
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
.
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.
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.
This worked for me.
mvn clean
mvn clean install
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