Leaderboard1

Leaderboard2

Wednesday, May 21, 2014

Create A Web Application Project With Maven

In this post we will learn to create Web Application using Maven. If Maven is not configured in your system, please refer this link; Configure Maven on Windows

Tools required:
  1. Eclipse IDE for Java EE Developers
  2. M2E plugin for Eclipse
  3. Maven
Steps:

1. Install Maven eclipse plugin

http://download.eclipse.org/technology/m2e/releases

You can install Maven plugin for Eclipse via update site, simply copy the above update site link address and paste it into Eclipse’s “Update” or “Install New Software” manager as explained below.


Restart Eclipse.

2. Create Dynamic Web project in eclipse

click next.

--> Create the following directory structure (please pay attention to the directory structure. It’s an important detail in the creation of Dynamic Web Project):


click next, and generate deployment descriptor, web.xml 

Press Finish.

Directory structure:


3. Convert to Maven project

Now right click on project, go to configure and click on "convert to Maven project".


  • Select “Packaging” as a WAR;
  • Click on the “Finish” button;
  • After that, pom.xml will appear in the project’s structure;
  • Move all stuff from the WebContent folder to src/main/webapp;
  • WebContent folder can be deleted after that.
4. Configuration for Eclipse
  • Go to projects root folder in cmd and run this: mvn eclipse:eclipse -Dwtpversion=2.0
  • This command will generate a configuration for eclipse (.classpath, .project, etc.).
  • Expand src > main and make a right click on the webapp folder: Build Path > Use as Source Folder (This point is actual only if src/main/webapp disappeared from the source folders).
Share this !

No comments:

Post a Comment