JavaGian java tutorial and java interview question and answer

JavaGian , Free Online Tutorials, JavaGian provides tutorials and interview questions of all technology like java tutorial, android, java frameworks, javascript, ajax, core java, sql, python, php, c language etc. for beginners and professionals.

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‘.
Console
$ 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

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.
Console
$ mvn eclipse:eclipse -Dwtpversion=2.0
convert to eclipse webproject
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
  2. Now, click on “Existing project..” in general section.
    Existing project menu
  3. Now, browse the project root folder and click OK. Finish.
    Browse project menu
  4. Above steps will import the project into eclipse work space. You can verify the project structure like this.
    project created success
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.

.