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.

Was this post helpful?

Related Posts

  • 28 January

    PowerShell – Get Number of Lines in CSV File

    Table of ContentsUsing Get-Content CmdletUsing Import-Csv CmdletUsing Get-ChildItem with Foreach-Object Using Get-Content Cmdlet The Get-Content cmdlet can be used in the following ways to get the number of lines in the specified .csv file: Get-Content cmdlet with .Length property Get-Content cmdlet with .Count property Get-Content cmdlet with .ReadCount property Get-Content cmdlet with Measure-Object cmdlet and […]

  • Read CSV file in PowerShell
    28 January

    Read CSV File in PowerShell

    Table of ContentsUsing the Import-Csv CmdletUsing the ConvertFrom-Csv CmdletUse the ConvertFrom-Csv Cmdlet with the Pipe (|) OperatorUse the ConvertFrom-Csv Cmdlet with the -InputObject Parameter Using the Import-Csv Cmdlet To read a CSV file in PowerShell, use the Import-Csv cmdlet. [crayon-63da5319a0323892820042/] [crayon-63da5319a032b041563757/] PowerShell provides several cmdlets that allow us to work with CSV files: Import-Csv ConvertFrom-Csv […]

  • Read File into String in PowerShell
    27 January

    Read File into String in PowerShell

    Table of ContentsUsing the Get-Content CmdletUse the Get-Content Cmdlet to Read a Single FileUse the Get-Content Cmdlet with forreach loop to Read Multiple FilesUsing [System.IO.File]::ReadAllText() MethodUse the [System.IO.File]::ReadAllText() Method with foreach loop to Read Multiple FilesUsing the Variable Notation with the Out-String Cmdlet Using the Get-Content Cmdlet We can use the Get-Content cmdlet to read […]

  • Get String between two characters in JavaScript
    27 January

    Get String Between Two Characters in JavaScript

    Table of ContentsUsing substring() MethodUsing slice() MethodUsing split() MethodUsing substr() Method 💡TL;DR Use the substring() method to get String between two characters in JavaScript. [crayon-63da5319a07fd937393413/] [crayon-63da5319a0803093083665/] Here, we got String between , and ! in above example. Using substring() Method Use the substring() method to extract a substring that is between two specific characters from […]

  • Remove property from Object in PowerShell
    27 January

    Remove Property from Object in PowerShell

    Table of ContentsUsing PSObject.Properties.Remove() MethodUsing -ExcludeProperty Parameter Using PSObject.Properties.Remove() Method To delete a property from an object in PowerShell, Use the New-Object cmdlet to create an object. Use the PSObject.Properties.Remove() method to remove a specific property from an object by providing the property’s name as a string parameter. [crayon-63da5319a0c1c107765567/] [crayon-63da5319a0c22098356884/] In the above code, we […]

  • Create File if not exists PowerShell
    26 January

    Create File If Not Exists in PowerShell

    Table of ContentsUsing the if-else StatementUse the New-Item CmdletUse the Out-File CmdletUsing the try-catch StatementUse the New-Item CmdletUse the Out-File CmdletUsing One-Liners Using the if-else Statement We can use the if-else statement to create a file as follows: Use the New-Item Cmdlet To create a file if it does not exist in PowerShell: Use the […]

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.