Converting a Netbeans project to a Maven enabled project

monksy picture monksy · Mar 31, 2011 · Viewed 70.2k times · Source

How can I transition a Netbeans generated project into accepting a Maven configuration? There are options to create Maven based projects, but there is nothing (that I've found so far) to add Maven dependencies to existing projects.

Answer

Jérôme Verstrynge picture Jérôme Verstrynge · Aug 4, 2011

You need to create a separate Maven Project. Then, you can copy the code from your other project to the Maven project. This can be done from the Projects windows in NetBeans.

Just select the code files/packages in the tree, right-click for copy, then paste them in the Source Packages of your new Maven project.

Next, open the files which Maven won't compile because they miss dependencies. The yellow bulb on the left of the problematic line will give you options to search for missing dependencies and add them to your project. You need to be online to perform searches.

You can also add maven dependencies manually in your new Maven project by right-clicking the dependencies folder in the Projects windows.