How to Create a Java Project with Maven in Eclipse

By Arvind Rai, August 22, 2013
We will create a java project with maven in eclipse. We will start from scratch and learn step by step.

1. Install Maven in your Window Click Here
2. Install Maven in eclipse Click Here
3. In eclipse we will create a simple java project for demo. I have created a java project named as JavaProject in my eclipse. There is a class . In our demo , there will be a apache logger to print the a message.
package com.concretepage;
import org.apache.log4j.Logger;
public class TestLogger {
	public static void main(String[] args) {
		Logger logger = Logger.getLogger(TestLogger.class);"Hello World!");
4. Create pom.xml in project root and configure dependency for log4j.jar.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi=""
  <version> 1.0-SNAPSHOT</version>
  <name>Java App with Maven</name>
5. Create in classpath.
log4j.rootLogger = DEBUG, A
# Set the appender named A to be a File appender
# Define the layout for A appender
6. Run pom.xml. Find link how to run pom.xml Click Here
7. Configure project .classpath for new downloaded jar by pom.xml Maven does this by a command. Go to project directory and run command
mvn eclipse:eclipse
8. We can use below mvn commands to manage project. clean, install, package, deploy, test etc.
9. Find the package structure in eclipse.

How to Create a Java Project with Maven in Eclipse

Download Source Code

©2023 | Privacy Policy | Contact Us