Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile)
Ensure compatibility between your Maven Compiler plugin and Java. You can achieve this with the following snippet:
Update: 3.8.1
to the latest, and don't forget to match <source>
/<target>
with your JDK. You can easily verify your JDK version through mvn -v
.
Dependencies and setup: Don't be afraid to 'clean' your room
Detox Your Maven cache
Sometimes, your local repository can have corrupted or outdated artifacts. Cleaning the .m2/repository
can resolve such issues.
Debug with Maven: No, it's not the latest reality TV show
You can use mvn clean install -X
for debug output, helping you underline the root cause of your problem.
Align your environment: The planets aren't the only thing needing alignment
Confirm JAVA_HOME points to your JDK and not a JRE. Especially important when working with WAR files.
Compatibility isn't just for speed dating
Verify compatibility between Maven, maven-compiler-plugin, and your JDK version.
Make sure to align source and target settings in maven-compiler-plugin
configuration.
Taking a path, and it's not the yellow brick road
Ensure your IDE's build path points to the JDK and not the JRE.
Debugging: It's not as scary as it sounds
Aligning Maven Run configuration: No, it's not a marathon
Verify the consistency between JDK versions in your IDE's Maven Run configuration and your pom.xml
.
Do your detective work on dependencies
Investigate your pom.xml
for any missing or wrongly included dependencies.
Stating clean: A new beginning every time
Always perform a mvn clean
before mvn install
to clear previous build artifacts.
Visualization
Imagine Maven is a determined puzzle assembler (🧩) but there's an issue; the puzzle piece (it's you!) just won't fit.
Maven's Compiler Plugin then acts like a strict school teacher (📐) that enforces the rules:
In simple English, this means Maven can't continue until everything fits into place.
Once you comply with the "school rules", Maven can assemble the puzzle successfully:
Getting proactive: Yes, you should prevent problems
Keeping up with the versions: Yes, you should!
Consider updating to the latest version of maven-compiler-plugin
to enjoy the latest bug fixes and compatibility improvements.
Maven and IDE need to play nice
Ensure your IDE's Maven plugin or integration is up-to-date. This helps avoid any tantrums between your command line and IDE.
Spring into action
If you're using Spring Tool Suite or similar, ensure that its Maven compatibility isn't causing any issues. The culprit may be a mismatch between your system's Maven and the embedded Maven.
Was this article helpful?