Creating a Simple Maven Project

Let us look at how to create a simple Maven project in IntelliJ Idea and deploy using Tomcat

For this project, you will need the following tools;
  1. IntelliJ Idea
  2. Maven downloaded and installed
  3. Tomcat downloaded and installed and configured to the IDE
1. Open IntelliJ Idea

2. Click Create New Project

3. Select Maven from the left panel.
    If you want to create project based on an archetype, click the check box and select the archetype.
    To create a basic project, click Next.
    (For this example, a basic project has been created)



4. Enter a name for the project and click Finish.

5. The following project will appear in the left pane.


As you can see, Maven creates the pom.xml file for the user whenever a new Maven project is created. The generates pom.xml file looks like this.


6. If you wish to create/add a dependency, right click on the pom.xml file and click Generate or press Alt+Insert


Click Dependency search for the relevant dependency that you wish to insert.

For this example, we will insert a junit dependency.


Select the dependency that you require by clicking Add. The dependency will appear as follows;


Any dependencies that you require can be added in the same manner.

7. By clicking Maven in the right hand panel, it is possible to view the options that could be done to the project.


By expanding Lifecycle, the user can run various actions that are shown by simply double clicking on them;


8. If you wish to view the dependencies as a diagram, simply right click on the name of the project in the right hand pane and click Show Dependencies.


This is show all the dependencies in the project diagrammatically, as shown below;



These are the basic steps of creating a simple Maven project and the actions that can be carried out.




Comments

Popular Posts