14

When I am try to build the project it gives this error.

Errors occurred during the build.
Errors running builder 'Maven Project Builder' on project 'ProjectName'.
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6
Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6
Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6

My Java version is 1.8 and Maven version is 3.2.5

And also when I first time configure Maven in my computer and I check that Maven configured correctly with mvn --version command and it works fine. But after restart my computer and checked Maven is work correctly. Then it says:

C:\Users\User Name>mvn --version
'mvn' is not recognized as an internal or external command,
operable program or batch file.
luk2302
  • 55,258
  • 23
  • 97
  • 137
NoughT
  • 675
  • 4
  • 20
  • 39

7 Answers7

11

Try the following steps:

  1. Make sure you have connectivity (you can browse) (This kind of error is usually due to connectivity with Internet)

  2. Download Maven and unzip it

  3. Create a JAVA_HOME System Variable

  4. Create an M2_HOME System Variable

  5. Add %JAVA_HOME%\bin;%M2_HOME%\bin; to your PATH variable

  6. Open a command window cmd. Check: mvn -v

  7. If you have a proxy, you will need to configure it

http://maven.apache.org/guides/mini/guide-proxies.html

  1. Make sure you have .m2/repository (erase all the folders and files below)

  2. If you are going to use Eclipse, You will need to create the settings.xml

Maven plugin in Eclipse - Settings.xml file is missing

You can see more detail in

http://maven.apache.org/ref/3.2.5/maven-settings/settings.html

Community
  • 1
  • 1
  • How do I get to know that I am using proxy. when I type just localhost in the browser it show me IIS 8 home page. (with out strat xampp) Is this matters ?? @Fernando – NoughT Jan 26 '15 at 08:45
  • 1
    You can run the command "ipconfig /all". This command show you "Primary DNS Suffix" and ""DNS Suffix Search List"" Also if you have a computer from your company, look your browser, for instance, IE you go: Tools > Internet Options > Connections > LAN settings > Proxy server – Fernando Castilla Jan 26 '15 at 09:06
  • There is no proxy in my computer. I am very confuse now – NoughT Jan 26 '15 at 11:11
  • If you do not use proxy you will not need to configure it. – Fernando Castilla Jan 26 '15 at 12:16
  • NoughT I have just edited to write more detail. Make sure you did everything – Fernando Castilla Jan 26 '15 at 12:26
  • There is no proxy and the path is properly configured. – Gani Dec 19 '18 at 06:27
4

Delete all files under the .m2 repository folder and rebuild the project.

  • 2
    Fixed the issue for me, after 2-3 hours of looking for a solution plausibly helpful to my situation. I'd recommend trying this before trying or reading anything more complicated, in case it fixes it, like it did for me. – Kartik Chugh Sep 15 '17 at 00:54
2

Try the following :

  1. Make sure you add M2_HOME variable to your environment variables. It looks like you might have set M2_HOME temporarily in a cmd window and not as a permanent environment variable. Also append M2_HOME to the PATH variable.

  2. Go to the m2 folder in your user directory.

    Example: On Windows, for user bot, the .m2 directory will be under C:\Users\bot. Look for the settings.xml file in this directory and look for the repository url within this file. See if you are able to hit this url from your browser. If not, you probably need to point to a different maven repository or use a proxy.

  3. If you are able to hit the repository url from the browser, then check if the repository contains the maven-resource-plugin version 2.6. This can be found by navigating to org.apache.maven.plugins folder in the browser. It's possible that your pom has hard-coded the dependency of the plugin to 2.6 but it is not available in the repository. This can be fixed by changing the depndency version to the one available in the repository.

Community
  • 1
  • 1
Chetan Kinger
  • 15,069
  • 6
  • 45
  • 82
  • I follow this tutorial to install maven.... [Maven in Windows](http://www.mkyong.com/maven/how-to-install-maven-in-windows/) – NoughT Jan 26 '15 at 08:34
  • I found the .m2 folder but there is no settings.xml file. What should I do?? @bot – NoughT Jan 26 '15 at 08:39
  • look this question about the settings.xml: http://stackoverflow.com/questions/5308079/why-maven-settings-xml-file-is-not-there – Fernando Castilla Jan 26 '15 at 09:01
2

Try update your Eclipse with the newest Maven repository as follows:

  1. Open "Install" dialog box by choosing "Help/Install New Software..." in Eclipse
  2. Insert following link into "Work with:" input box http://download.eclipse.org/technology/m2e/releases/
    and press Enter
  3. Select (check) "Maven Integration for Eclipse" and choose "Next >" button
  4. Continue with the installation, confirm the License agreement, let the installation download what is necessary
  5. After successful installation you should restart Eclipse
  6. Your project should be loaded without Maven-related errors now
0

This helped me: I created a new maven project which was working fine in my old workspace, but gave above errors in the new workspace. I had to do the following: - Open old workspace on Eclipse - open Preferences tab - Search Maven in filter - Copy the path for settings.xml from User Settings - User Settings - Switch to new workspace - Update the preferences - Maven - User Settings - User Settings path

After the build is completed, all errors are resolved.

0

I had a similar problem in spring tool suite(sts). THE .m2 repository was not completely downloaded in the local system which is the reason why I was getting this error. So I reinstalled sts and deleted the old .m2 repository from the system and created a new maven project in sts which downloaded the complete .m2 repository. It worked for me.

0

Step1: Delete all instances of java from you machine

Step2: Delete all the environment variables related to java/jdk/jre

Step3: Check in programm files and program files(X86) folder, there should not be java folder.

Step4: Install java again.

Step5: Go to cmd and type "java -version" Result: it will display the java version which is installed in your machine.

Step6: now delete all the files which are in C:/User/AdminOrUserNameofYourMachine/.m2 folder

Step6: go to cmd and run "mvn -v" Result: It will display the Apache maven version installed on your machine

Step7: Now Rebuild your project.

This worked for me.