Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create the pom.xml for a Java project with Eclipse

I already have a small Java project. I want to move it to Maven, so I want to create the pom.xml using Eclipse so that I can build it using pom from a command prompt. I have not worked with Maven before, though I have worked with Ant.

How can I create the pom.xml for my Java project using Eclipse?

like image 769
M Sach Avatar asked Jan 11 '12 10:01

M Sach


People also ask

What is POM xml in Eclipse?

What is a POM? A Project Object Model or POM is the fundamental unit of work in Maven. It is an XML file that contains information about the project and configuration details used by Maven to build the project. It contains default values for most projects.

Where is POM xml in Java project?

The src/main/java directory contains the project source code, the src/test/java directory contains the test source, and the pom. xml file is the project's Project Object Model, or POM.

How do I add POM xml to an existing project?

In the Project tool window, right-click your project and select Add Framework Support. In the dialog that opens, select Maven from the options on the left and click OK. IntelliJ IDEA adds a default POM to the project and generates the standard Maven layout in Project tool window.


2 Answers

You should use the new available m2e plugin for Maven integration in Eclipse. With help of that plugin, you should create a new project and move your sources into that project. These are the steps:

  • Check if m2e (or the former m2eclipse) are installed in your Eclipse distribution. If not, install it.
  • Open the "New Project Wizard": File > New > Project...
  • Open Maven and select Maven Project and click Next.
  • Select Create a simple project (to skip the archetype selection).
  • Add the necessary information: Group Id, Artifact Id, Packaging == jar, and a Name.
  • Finish the Wizard.
  • Your new Maven project is now generated, and you are able to move your sources and test packages to the relevant location in your workspace.
  • After that, you can build your project (inside Eclipse) by selecting your project, then calling from the context menu Run as > Maven install.
like image 163
mliebelt Avatar answered Sep 21 '22 21:09

mliebelt


This works for me on Mac:

Right click on the project, select ConfigureConvert to Maven Project.

like image 45
xiaoxxcool Avatar answered Sep 23 '22 21:09

xiaoxxcool