sheetal
sheetal

Reputation: 199

How to create a Maven project in Eclipse

I want to create a web application project in Eclipse with Maven. Everytime I try to create the project I get an error as "Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:RELEASE from any of the configured repositories".

I have checked for solutions presented in other questions tried them, but none of them solved the issue. I have also changed my settings.xml file to point it to proxy even that didn't help. I also tried deleting the repositries folder in .m2.

Please suggest some solutions for this

Upvotes: 2

Views: 1557

Answers (3)

Jonathan Benn
Jonathan Benn

Reputation: 3589

I was recently struggling to create a new Maven project in Eclipse. Trying to create a Dynamic Web Project first and then converting it into a Maven project did not work (none of the Java integration was working and my code wouldn't even compile)!

The following article describes how to create a Maven project in Eclipse. The tutorial recommends skipping the archetype part, which might solve the issue described in the original question:

https://www.tech-recipes.com/rx/39279/create-a-new-maven-project-in-eclipse/

If that doesn't work for you, perhaps doing a clean install with the latest version of Eclipse, in a new directory, may help. What you described might just be a bug in Eclipse or one of its installed plugins.

Upvotes: 0

Matthew Cachia
Matthew Cachia

Reputation: 4712

That is quite a weird issue ... however m2eclipse gave me my fair share of problems when I tried to create my projects. In fact, I ended up creating the archetypes myself!

Let me share my maven 3 POM file:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.example</groupId>
  <artifactId>example-project</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>

  <dependencies>
        <!-- add your dependencies here -->
  </dependencies>

  <build>
    <finalName>example-project</finalName>
    <pluginManagement>
        <plugins>

            <!-- v. useful! m2eclipse sometimes fails to see it as a 
                 dynamic web app project in Eclipse. Declaring this plugin 
                 would help eclipse recognize its nature (i.e. a Java 
                 project requesting at least JDK1.7+ -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>

        </plugins>
    </pluginManagement>
  </build>
</project>

Running mvn eclipse:eclipse on this project should work. You can safely import to eclipse as a maven project as well (File > Import > Existing Maven Projects) If it doesn't, then you should consider re-installing a fresh copy of maven.

Let me know if you manage to get it up and running. :)

Upvotes: 0

Mahender Yadav
Mahender Yadav

Reputation: 344

  1. Open Window > Preferences
  2. Open Maven > Archetypes
  3. Click 'Add Remote Catalog' and add the following:

Upvotes: 1

Related Questions