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:
- Eclipse IDE for Java EE Developers
- M2E plugin for Eclipse
- 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.
- 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).
No comments:
Post a Comment