Contents

Creating the project in Eclipse

Now that we installed Eclipse with Maven support let's concentrate on our project. First off, we need a new project and we want it to be a Maven project. Maven projects have a standard directory layout and always contain a pom.xml file. Pom.xml is used to define project configurations that Maven will handle, such as dependencies that your projects needs (log4j, spring, hibernate, junit, etc) and plugins.  

Creating a new Maven project in Eclipse

Follow these steps to create a simple Maven project. We are going to expand this project later in order to turn it into a functioning web application. Note: we will let Eclipse build the initial structure, but you van do this manually if you want. It's a simple structure that follows Maven's Standard Directory Layout.

  1. Choose File > New > Project...
  2. In the New Project window open the Maven folder and choose Maven Project.

    New Maven project window
  3. Check the option "Create a simple project (skip archetype selection)". A Maven archetype is a project template. An archetype automatically creates a folder structure and files for you. We are not using an archetype, because I prefer creating everything myself. so that I know 100% what I am doing.
  4. In the next screen fill out the Group Id, Artifact Id, Packaging and Name

    Maven config for Eclipse project

    The Group Id is usually a reversed domain name. The Group Id will be part of the package names in your project.

    You can make up an Artifact Id yourself. Usually this is the application name in lowercase, with spaces replaced by hyphens.

    The Packaging type is war in our case, because we are building a complete web application.

    You can make up a Name yourself.
     
  5. Click Finish to create the project and the structure below will be generated.

    Eclipse project explorer

A new project was generated that follows Maven's Standard Directory Layout. A Maven project consists of a src folder with main and test subfolders. In the main folder there is a folder for Java code (src/main/java) and a folder for resources like configuration files (src/main/resources).

The pom.xml file is where project dependencies and plugins are defined using XML. 

On the next page we will expand our project structure a little more and after that we will take a closer look at Maven.