In this article we will see how to use Maven to setup web application project in Eclipse.
- I am using Eclipse as the IDE, version Luna 4.4.1.
- Apache Maven is a software project management and comprehension tool. It manages the project build using the project object model (POM) XML.
Download Maven and Install Maven-Eclipse Plugin
Posts about Sample Project in ECLIPSE written by Anshu. A)Create Web-Project(Eclipse,Tomcat&Database) Dynamic Web Project is used to develop, debug and deploy dynamic web applications in eclipse.For this project. Getting Started with WebDriver-Selenium for Java in Eclipse Getting started with WebDriver’s Java bindings is easy -- if you know how to connect the pieces together. Once the pieces are in place, development is a snap.
- Download Maven.
- If you haven’t used Maven before in Eclipse then you may also need to install theMaven-Eclipse plugin.
- You need to click on the Help->Install New Software. Enter http://download.eclipse.org/technology/m2e/releases in ‘Work with’ an click on Add.
- Select Maven plugin. Click on Next and then Finish.
Maven Eclipse Plugin
Now that we have installed Maven and Eclipse-Maven plugin, we will be able to create Maven Projects. Let’s create one.
MavenProject
Click on File->New->Other
Click on ‘Maven’->’Maven Project’
Maven Project
We now need to select archetype so leave ‘Create Simple Project’ unchecked and move ahead.
Maven Project Main Screen
Now what is an archetype?
Archetype is a Maven project templating toolkit which means we can select one of its template it will create a sample project for us. In our case, we want a web-app so we will enter ‘org.apache.maven.archetypes’ in filter and then select row with Artifact-id as ‘maven-archetype-webapp’. This will create sample Maven Webapp project. Once selected, click on Next.
Maven Archetype Web-app
Now that we have created a template, enter your own ArticfactId and GroupId.
In order to just run the sample app, we still need servlet api. Let’s add javax.servlet-api
to our pom.xml
, version 3.1.0.
If you don’t see Simply create a java directory under main (i.e. src/main/java) and right-click on your project and select Maven > Update Project Configuration.
The project structure should look like below:
Run the web application
Now let’s run our webapp. It should open up a browser and display ‘Hello World’ page.
We will be using tomcat as our server.
If you have configure more than one tomcat or not yet configure, this is time to do and select one.
Select Tomcat Server
Once tomcat is selected and clicked on Finish, our web application will open up.
Webapp ‘Hello World’ page
Eclipse
Download the Eclipse Project
This was an example about creating web application project in Eclipse using Maven. You can download the source code here: webAppExample.zip
This free video tutorial will help get you started writing Javaprograms using Eclipse version 3.3. Noprior experience with Eclipse or Java is assumed. The 16 lessons totalabout 3 1/4 hours and are each between 9 and 14 minutes long. Thelessons guide you through a step-by-step process creating a simple'personal lending library' application. Each lesson is fullynarrated.
All of the code for the lessons is typed in 'realtime'. This allows the demonstration of many Eclipse Java editorfeatures that speed up coding. Code snapshots as of the end of eachlesson are provided in the Tutorial CompanionGuide. These allow you to jump in at any lesson and to make sure yourcode matches the sample code.
Eclipse Download
Test-driven development is used throughout the lessons, using the JUnittesting facility in Eclipse. The lessons are designed for you to workside-by-side, pausing and rewinding the video as needed. See the TutorialCompanion Guide for more information about the tutorial, or look at thetutorial lesson outlines.
You can view all of the tutorials on Youtube or you can download them at theproject download page. Be sure to download the Tutorial CompanionGuide (PDF format).
Eclipse Java Download
The tutorials use Eclipse version 3.3(Europa), released June 2007.
Now Available with Hungarian Captions
Sample Java Application Projects
This tutorial is being released with Hungarian captions. Lessons 1 - 6and the Tutorial Companion Document are available for immediatedownload. Hungarian captions for Lessons 7 - 16 will be completed inJune.