Converting a Netbeans project to a Maven enabled project
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.
If you are familial with maven, then you can always configure maven even in the later, however it is not recommended.
the only reason behind people(including me ;) ) recommend to create a new maven project, is Maven has it's own directory structure. And that is standard. now if you want to enable maven for your project at a later stage, than you can configure the things in pom.xml, i.e. your source directory, target directory and web app directory(if applicable)
I had a large project in SVN and was disallowed to create a new project. I did not want to support lib management and so I configured maven according to my directory structure.
here's the part of my pom.xml
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>testpackages</testSourceDirectory>
<testOutputDirectory>target/test-classes</testOutputDirectory>
<plugins>
<plugin>
<version>2.3.2</version>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>web-root</directory>
</resource>
</webResources>
</configuration>
</plugin>