Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a Maven project in Eclipse complains "Could not resolve archetype" [duplicate]

I am totally a newbie with Maven. I want to create a Maven project with Eclipse Juno EE with archetype "webapp". I installed "Maven Integration for Eclipse WTP (incubation)" and I also have installed "Maven Integration for Eclipse" (found it on Installed tab of Eclipse Marketplace). When I try to create new Project from File->New_>Maven Project, I obtain error:

 Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:RELEASE from any of the configured repositories. Could not resolve artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE Failed to resolve version for org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml in local (C:\Documents and Settings\PEP35KD\.m2\repository) Failed to resolve version for org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml in local (C:\Documents and Settings\PEP35KD\.m2\repository) 

It happens for all kinds of archetype. I am using a proxy, and I create file settings.xml under C:\Documents and Settings\PEP35KD.m2\ with this content:

<proxies>     <proxy>         <id>myId</id>         <active>true</active>         <protocol>http</protocol>         <username>rete\pep35kd</username>         <password>XXXX</password>         <host>XXXX</host>         <port>8080</port>         <nonProxyHosts>localhost</nonProxyHosts>     </proxy> </proxies> 

Please, consider that it seems that I cannot use mvn command from command line (command not found). I never installed Maven itself, I thinked that plugin is just enough: is it a correct assumption?

UPDATE Problem is definitely related to proxy. By:

  • Installing Maven on local PC;
  • Installing Maven Eclipse from Eclipse Market Place;
  • Setting Maven Install directory to local PC Maven dir, instead of default Embedded Maven,

everything works as expected. I cannot really understand why, but probably firewall is blocking traffic with Maven servers.

like image 550
marcos82 Avatar asked Mar 19 '13 17:03

marcos82


People also ask

What should be the archetype for Maven project in Eclipse?

If you want a web application, use maven-archetype-webapp, or if you want a simple application use maven-archetype-quickstart. They are useful because you will be able to expand them with no problem. Note that this is in the Eclipse plugin by default (at least it is today).

How do I change my Maven archetype in eclipse?

So if you want to change your project nature you've to do it "by hand". It seems that in your case, you just have to change in pom. xml, the package type to war and to proceed a "Maven update project" in your IDE so maven plugin will update configuration. Perfect Answer!


2 Answers

I fixed this problem by following the solution to this other StackOverflow question

I had the same problem. I fixed it by adding the maven archetype catalog to eclipse. Steps are provided below: (Please note the https protocol)

  1. Open Window > Preferences
  2. Open Maven > Archetypes
  3. Click 'Add Remote Catalog' and add the following:
    • Catalog File: https://repo1.maven.org/maven2/archetype-catalog.xml
    • Description: maven catalog
like image 188
TomDestry Avatar answered Sep 23 '22 19:09

TomDestry


Assuming that you have your proxy settings correct, you may have missed out pointing Eclipse to the intended settings.xml file. This happens often when you have both Maven installed as a snap in, and an external installation outside Eclipse. You need to tell Eclipse which Maven installation it should use, and which settings.xml file it should be looking for.

First check that the settings.xml file contains your proxy settings.

enter image description here

Next, check that the user settings.xml file here contains your proxy settings.

enter image description here

If you have made any changes, restart Eclipse.

like image 28
Oh Chin Boon Avatar answered Sep 24 '22 19:09

Oh Chin Boon