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?
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. Required fields are marked *