Issue
I downloaded a Java package from Git and encountered an error while trying to compile the JAR using Maven. The error states:
[ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved.
System Details
- Java Version: JDK 1.7.0_79 (Installed because the project uses Java 17)
- Maven Version: 3.8.8
- No proxy or network restrictions
- Tried on multiple machines
- Removed settings from
settings.xml
(profiles, proxies, mirrors)
Despite these efforts, the error persists.
Causes & Fixes
1. Incorrect Java Version
Your project requires Java 17, but you have Java 1.7.0_79 (which is very outdated).
Solution:
- Check your Java version:
java -version javac -version
Ensure they show Java 17 or later. - Set JAVA_HOME properly
On Linux/macOS:
export JAVA_HOME=/path/to/java17
export PATH=$JAVA_HOME/bin:$PATH
On Windows (PowerShell):
$env:JAVA_HOME="C:\Path\To\Java17"
$env:Path="$env:JAVA_HOME\bin;$env:Path"
Restart the terminal and retry.
2. Corrupted or Missing Dependencies
If Maven is unable to download plugins, your local repository might be corrupted.
Solution:
Run the following command to delete the corrupted files:
rm -rf ~/.m2/repository/org/apache/maven/plugins
On Windows:
rd /s /q %USERPROFILE%\.m2\repository\org\apache\maven\plugins
Then, force Maven to re-download dependencies:
mvn clean install -U
3. Outdated Maven Version
Maven 3.8.8 is good, but Maven 3.9.x has better dependency resolution.
Solution:
- Download the latest Maven: Apache Maven Official Site
- Extract and update
MAVEN_HOME
- Verify:
mvn -version
4. Try an Alternate Repository
If Maven Central is failing, try switching to another repository (like Google’s or JitPack).
Solution: Add this to your settings.xml
:
<mirrors>
<mirror>
<id>central</id>
<mirrorOf>central</mirrorOf>
<url>https://repo1.maven.org/maven2/</url>
<layout>default</layout>
</mirror>
</mirrors>
Then, retry:
mvn clean install
Final Steps
After applying the above solutions, restart your terminal and try again:
mvn clean install
This should fix the issue. If you’re still stuck, let me know!