HowToDoInJava

  • Python
  • Java
  • Spring Boot
  • Dark Mode
Home / Maven / Create maven web project in eclipse step by step

Create maven web project in eclipse step by step

Learn to create maven web project in eclipse which we should be able to import on eclipse IDE for further development.

To create eclipse supported web project, we will need to create first a normal maven we application and then we will make it compatible to eclipse IDE.

1. Create maven web project in eclipse

Run this maven command to create a maven web project named ‘demoWebApplication‘. Maven archetype used is ‘maven-archetype-webapp‘.

$ mvn archetype:generate 
			-DgroupId=com.howtodoinjava 
			-DartifactId=demoWebApplication
			-DarchetypeArtifactId=maven-archetype-webapp 
			-DinteractiveMode=false

This will create maven web project structure and web application specific files like web.xml.

create-web-project-using-maven-1844893

2. Convert to eclipse dynamic web project

To Convert created maven web project to eclipse dynamic web project, following maven command needs to be run.

$ mvn eclipse:eclipse -Dwtpversion=2.0

convert-to-eclipse-webproject-9798545

Please remember that adding “-Dwtpversion=2.0” is necessary, otherwise using only “mvn eclipse:eclipse” will convert it to only normal Java project (without web support), and you will not be able to run it as web application.

3. Import web project in Eclipse

  1. Click on File menu and click on Import option.
    import-project-menu-9106164
  2. Now, click on “Existing project..” in general section.
    existing-project-menu-9473492
  3. Now, browse the project root folder and click OK. Finish.
    browse-project-menu-2890673
  4. Above steps will import the project into eclipse work space. You can verify the project structure like this.
    project-created-success-4773138

In this maven tutorial, we learned how to create maven dynamic web project in eclipse. In this example, I used eclipse oxygen. You may have different eclipse version but the steps to follow will be same.

Happy Learning !!

Was this post helpful?

Let us know if you liked the post. That’s the only way we can improve.
TwitterFacebookLinkedInRedditPocket

About Lokesh Gupta

A family guy with fun loving nature. Love computers, programming and solving everyday problems. Find me on Facebook and Twitter.

Feedback, Discussion and Comments

  1. rijesh

    October 25, 2016

    Hi Lokhesh,

    I am getting this error

    NFO] Generating project in Interactive mode
    ARNING] No archetype found in remote catalog. Defaulting to internal catalog
    NFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
    oose archetype:
    internal -> org.apache.maven.archetypes:maven-archetype-archetype (An archetype which contains a sample archetype.)
    internal -> org.apache.maven.archetypes:maven-archetype-j2ee-simple (An archetype which contains a simplifed sample J2EE application.)
    internal -> org.apache.maven.archetypes:maven-archetype-plugin (An archetype which contains a sample Maven plugin.)
    internal -> org.apache.maven.archetypes:maven-archetype-plugin-site (An archetype which contains a sample Maven plugin site.
    This archetype can be layered upon an existing Maven plugin project.)
    internal -> org.apache.maven.archetypes:maven-archetype-portlet (An archetype which contains a sample JSR-268 Portlet.)
    internal -> org.apache.maven.archetypes:maven-archetype-profiles ()
    internal -> org.apache.maven.archetypes:maven-archetype-quickstart (An archetype which contains a sample Maven project.)
    internal -> org.apache.maven.archetypes:maven-archetype-site (An archetype which contains a sample Maven site which demonstrates
    some of the supported document types like APT, XDoc, and FML and demonstrates how
    to i18n your site. This archetype can be layered upon an existing Maven project.)
    internal -> org.apache.maven.archetypes:maven-archetype-site-simple (An archetype which contains a sample Maven site.)
    : internal -> org.apache.maven.archetypes:maven-archetype-webapp (An archetype which contains a sample Maven Webapp project.)
    oose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): 7: -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
    oose archetype:
    Your filter doesn’t match any archetype (hint: enter to return to initial list)
    oose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): : 2
    oose archetype:
    Your filter doesn’t match any archetype (hint: enter to return to initial list)
    oose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): : 1
    choose archetype:
    Your filter doesn’t match any archetype (hint: enter to return to initial list)
    oose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): : 1.2
    oose archetype:
    Your filter doesn’t match any archetype (hint: enter to return to initial list)
    oose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): : mvn eclipse:eclipse -Dwtpversion=2.0
    oose archetype:
    Your filter doesn’t match any archetype (hint: enter to return to initial list)
    oose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): :

    • Lokesh Gupta

      October 25, 2016

      Please verify that you are using “archetypeArtifactId”.

  2. vineet Kumar

    May 27, 2015

    Hi Lokesh,

    Thanks for sharing this nice tutorials.
    I have a doubt about test folder which should be inside src folder. It is not there.
    Do I need to add this(i.e test) folder manually?

    Thanks,
    Vineet Kumar

    • Lokesh Gupta

      May 27, 2015

      Yes, you have to create manually. Read this tutorial : Creating java source folders in maven web application

  3. chaudharisuresh01@gmail.com

    May 3, 2014

    i want very simple demo of struts spring hibernate please help

    • Lokesh Gupta

      May 3, 2014

      I will work on it.

  4. Biswajit Samal

    April 30, 2014

    Hi,

    I am biswajit , using selenium webdriver for testing. I want to convert my project to maven project. While doing so, it is showing an error.

    Can you pls guide me. I am seriously need help on Maven and configuring my pom.xml,

    Thanks in advance.

    • Lokesh Gupta

      April 30, 2014

      What’s error?

  5. Bibhash Roy

    February 14, 2014

    I am getting the following error message (eclipse project with a red cross) after importing the project – “Java compiler level does not match the version of the installed Java project facet. – Unknown Faceted Project Problem (Java Version Mismatch)” Please help

    Surprising I am helios which is supposed to support WTP 3.2 but I used WTP 2.0 since my WTP plugin support upto 2.0 only….what is the source of problem?

    • Lokesh Gupta

      February 14, 2014

      Read this: https://howtodoinjava.com/maven/solved-java-compiler-level-does-not-match-the-version-of-the-installed-java-project-facet/

  6. chandu

    February 9, 2014

    Hi Lokesh,
    while i run the -DarchetypeArtifactId=maven-archetype-webapp ” i am getting error like :’-DarchetypeArtifactId’ is not recognized as an internal or external command,
    operable program or batch file. please correct me.

    • Lokesh Gupta

      February 10, 2014

      “mvn archetype:generate -DgroupId=com.howtodoinjava -DartifactId=demoWebApplication -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false” is actually a single command. Remore any line break if there is any.

  7. Manish

    December 23, 2013

    Not able to successfully run the mvn command:
    Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate on project standalone-pom: The desired archtype does not exist

  8. chaitanya

    December 6, 2013

    Sir, what is the meaning of wtpversion?? why we are giving only 2.0 as the version value?? cant we give any other value like “ch.1.000.200.1” etc..

    • Lokesh Gupta

      December 7, 2013

      wtp adds web application support to eclipse.
      Read more: http://wiki.eclipse.org/WTP_FAQ#What_version_of_Eclipse_does_WTP_work_with.3F

  9. suparna

    November 21, 2013

    I am getting this error after entering mvn archetype:generate -DgroupId=com.howtodoinjava -DartifactId=demoWebApplication
    -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false in cmd

    Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven- clean-plugin/2.5/maven-clean-plugin-2.5.pom
    clean-plugin/2.5/maven-clean-plugin-2.5.pom
    [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
    n-clean-plugin:2.5: Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or on
    e of its dependencies could not be resolved: Failed to read artifact descriptor
    for org.apache.maven.plugins:maven-clean-plugin:jar:2.5

    Please solve this issue

    • Lokesh Gupta

      November 21, 2013

      If you are behind some firewall then try configuring proxy settings.

  10. Rajendra Joshi

    January 3, 2013

    runs correctly very fine

Comments are closed on this article!

Search Tutorials

Maven Tutorial

  • Maven – Installation
  • Maven – Settings
  • Maven – Dependency Mgmt
  • Maven – Dependency Scopes
  • Maven – POM
  • Maven – Parent POM
  • Maven – Repositories
  • Maven – Local Repo Path
  • Maven – M2_REPO
  • Maven – Network Proxy
  • Maven – Enforce Java Versions
  • Maven – Simple Java Project
  • Maven – Web Project
  • Maven – Multi-module Project 1
  • Maven – Multi-module Project 2
  • Maven – Java Source Folders
  • Maven – BOM [Bill Of Materials]
  • Maven – Import Remote Catalogs
  • Maven – Create Custom Archetype
  • Maven – Compiler Level Mismatch
  • Maven – Ant Build
  • Maven – IntelliJ
  • Maven – JSTL Support
  • Maven – Tomcat Plugin
  • Maven – Uber Jar for Spring Boot
  • Maven – Shade Plugin
  • Maven – Remove corrupt jars

Meta Links

  • About Me
  • Contact Us
  • Privacy policy
  • Advertise
  • Guest and Sponsored Posts

Recommended Reading

  • 10 Life Lessons
  • Secure Hash Algorithms
  • How Web Servers work?
  • How Java I/O Works Internally?
  • Best Way to Learn Java
  • Java Best Practices Guide
  • Microservices Tutorial
  • REST API Tutorial
  • How to Start New Blog

Copyright © 2020 · HowToDoInjava.com · All Rights Reserved. | Sitemap

  • Sealed Classes and Interfaces