How to create dynamic web project using maven in eclipse

In this post, we will see how to create dynamic web project using maven in eclipse. If you can also create simple java maven project in eclipse.

I am using following tools for this post.

  • eclipse-jee-mars-R-macosx-cocoa-x86_64
  • Apache tomcat 8
  • m2eclipse plugin
  • jdk 1.7

Steps for creating dynamic web project using maven in eclipse.

1) Install m2eclipse for maven plugin in eclipse. Please follow this link for installing m2eclipse plugin in eclipse.

2) goto new -> project-> Maven Project and click on next

3) You will see below screen , again click on next

4) We need to select type of archetype here.As we are creating web app here, please put following text in filter : maven-archetype-webapp

5) We need to put group id and artifact id here.

Let me tell you more about group id and artifact id.

Group id : It uniquely identifies your project among all. So it may be something like com.companyname

Artifact id : It is name of jar or war without version. it may be something like project, so here we have put artifact id as mavenWebApp

Version : Version is used for version control for artifact id. If you distribute this project, you may incrementally create different version of it.

6) You project structure should look something like below image.

7) When I have followed above steps, I was getting below error.
“The superclass “javax.servlet.http.HttpServlet” was found in java build path”.

You can resolve this error using two ways.

1) you can add following dependency to pom.xml

2) you can set target run time as Apache tomcat .
right click on project -> properties -> target runtimes

8) It ‘s time to do maven build.
Right click on project -> Run as -> Maven build

9)  Provide goals as clean install (given below) and click on run

10) When you run maven build, you will see below screen

11) Deploy this application to tomcat server and run it.
If you don’t have tomcat server configured in eclipse, follow these steps.
Right click on project -> run as -> run on server -> choose tomcat.

12)
When you run application, you will get following output:

Bingo !! we are done with creating dynamic web project using maven in eclipse.

Please comment if you are facing any issue with this.

Related Posts

  • Check if String contains Substring in PHP
    25 October

    How to check if String contains substring in PHP

    Table of ContentsIntroductionHow to check if a string contains substring in PHP?1) strpos() function:2) strstr() function:3) stristr() function:4) preg_match() function: Introduction A string is a sequence of characters used as a literal constant or variable. The specific part of a string is known as a substring. In this article, we will see different ways to […]

  • 25 October

    Increment operator in python

    Table of ContentsPython’s distinct way of using the increment operatorWays to increment a variable in PythonUsing the augmented assignment operatorUsing the step parameter in the range() functionThe role of immutability in Python The increment process is among the basic and the essentials of any programming language. We use it in problem-solving and when there is […]

  • Initialize list with zeros in Python
    25 October

    Four Ways To Initialize List With Zeros In Python

    Table of ContentsWhy Initialize List with Zeros in Python?How Can We Initialize List With Zeros In Python?Initialize List With Zeros Using * Operator In PythonInitialize List With Zeros Using  itertools.repeat() FunctionInitialize List With Zeros Using  Generator Comprehension In PythonInitialize List With Zeros Using  List Comprehension In PythonConclusion Lists in Python are one of the most […]

  • How to print an array in PHP
    19 October

    How to print an array in PHP

    Table of ContentsIntroductionHow to print an array in PHP?1) print_r() function:2) var_dump() function:3) json_encode() function:4) foreach() loop: Introduction An array is one kind of data structure, which can store multiple items of related data types. The printing of an array is one of the fundamental functions of PHP. How to print an array in PHP? […]

  • Multiple classes in one file in Java
    18 October

    Multiple classes in one file in Java

    Table of ContentsIntroductionMethods to Implement Multiple Classes In One Java Program1) Nested classes2) Multiple non-static nested classes In this post, we will see how to have multiple classes in one file in java. Introduction You need to have any number of classes in a single Java file, but there is a restriction that you can […]

  • How to initialize empty array in PHP
    18 October

    Declare empty array in php

    Table of ContentsUsing square brackets to declare empty array in PHPUsing array() to declare empty array in PHP An array is a data structure where you can store the same or different types of data in a single variable. In PHP, you can declare empty array using square brackets ([]) or using array() function. Using […]

Comments

  1. Hi,

    Many thanks for the tutorial. A couple of erratas: groupid should be groupID and artifactid should be artifactId in dependency definition.

    Thanks and best regards

  2. Awesome! Thanks so much. Just the uncomplicated basics. Just what I needed. Bookmarked for future reference!

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.