Create Maven WAR Project Eclipse

Create Maven WAR Project Eclipse

In this tutorial you will see how to create maven war project in eclipse. We will use Eclipse Kepler version which comes with built-in maven plug-in. You could either Eclipse Kepler or higher version which comes with maven plug-in. Please follow steps below:

  • Open your eclipse
  • Click File –> New –> Other –> Maven –> Maven Project then click Next:

Create Maven WAR Project Eclipse

  • Next screen keep all default then click Next:

Create Maven WAR Project Eclipse

  • On next window choose maven-archetype-webapp and click Next:

Create Maven WAR Project Eclipse

  • Next window enter below and click Finish:

Create Maven WAR Project Eclipse

  • Now you will see new project name MavenWARProject got created. To check what kind of packaging it is. Double click to open pom.xml file and in overview tab you will below war packaging:

Create Maven WAR Project Eclipse

  • In newly created project in eclipse you will see red cross error this is because it is web based project and it needs run time servlet from server. Please attach server library using this tutorial

Create Maven WAR Project Eclipse

  • After adding server run time library you will see error got disappeared. Below is final project structure:

Create Maven WAR Project Eclipse

  • To package this project in WAR file: Right click pom.xml –> Run As –> Maven Install. This will clean compiles source code, execute unit test, packaging them in War file and put them in target folder.

Create Maven WAR Project Eclipse

  • Once you see message BUILD SUCCESS on the console refresh and open target folder you will see War file got created.

Create Maven WAR Project Eclipse

  • Now you could copy and deploy this file on any server. For this demo we deployed on tomcat server with below output:

Create Maven WAR Project Eclipse

  • That’s it for more information about Apache War project please refer their tutorial here

Leave a Reply

Your email address will not be published. Required fields are marked *

I am not Robot *