How to convert an existing Java Project to Maven in Eclipse?

By | October 26, 2020

This tutorial talks about Converting an existing Java Project to Maven in Eclipse?

I have a Non-Maven Spring Project which I want to convert into a maven project.

Before converting an existing Java Project to Maven in Eclipse:

Steps to convert an existing Java Project to Maven in Eclipse:

Step 1: Right-click on your java project and go to Configure and you should see the “Convert to Maven Project” option.

Step 2: Provide group id and artifact id, I have kept the default.

Let me explain to you more about group id and artifact id.

Group id : It is a unique identifier for your project among all. So it may be something like com.companyname

Artifact id : It is the name of jar or war without a version. it may be something like a project, so here we have put artifact id as SpringApplicationContextDemo.

Click on the finish button.

Step 3:
Just remember to put all dependencies in pom.xml

Step 4: Now right on converted maven project then go to maven ->Update Project

Step 5. Select Your Project & Force Update of Snapshots/Releases. Click on OK

Finally, the Maven Project would look like this:

Note: Still this conversion process has a problem like you will not find standards project directory structures src/main/java and src/test/java, You can solve this issue manually(Still you can build and run the project successfully).

Complete source code of the above Project:

pom.xml

Employee.java

ClientTest.java

applicationContext.xml

 If You right-click on ClientTest.java and Run AS -> Java Application. I will give below output

 

That’s all about Convert an existing Java Project to Maven in Eclipse?

You May Also Like:

What is Maven?
How to install and setup Maven Environment on windows?
Create a maven project using the command line
How to import the maven project in Eclipse?
How to Create a New Maven Project in Eclipse
How to create a maven web application project in Eclipse
How to create a multi-module project using maven?
How to Fix missing src/main/java & src/test/java folders in the Eclipse Maven web Project?
How to create user-defined properties in Maven?
What is the maven local repository location & how to change it?
How to add or update the maven settings.xml file in eclipse?
Importing maven remote Archetype Catalogs in eclipse ?
What is POM in the maven Project?
What is Super POM in Maven Project?
Understanding the purpose of Maven Plugin
Compiling the Maven project with different JDK versions? 
Understanding of settings.xml in maven
How to enable a proxy setting in Maven?
Maven Dependency Scopes
How to generate javadoc in the maven Project
How to create a runnable JAR file with Maven?
How to add local jar files to a Maven project?
How to exclude dependency in maven?
Managing External Dependencies in maven
Understanding of Maven Repositories
What is an archetype in Maven?
Snapshot Vs Version in maven
Apache Maven – Profiles

If you have any feedback or suggestion please feel free to drop in below comment box.

Leave a Reply

Your email address will not be published.