Converting a Netbeans project to a Maven enabled project

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.


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

                        <!-- this is relative to the pom.xml directory -->

I follow these steps for my desktop Java application (backup your project before doing this):

  1. Open your project in Eclipse (by going to new project and browse to your project). Importing the project will not work.

  2. Enable maven for this project

  3. Add dependency library

  4. Close your project

  5. Delete NBProject folder and Build.xml from the project location (otherwise NetBeans will not able to recognize it as maven project).

  6. Open this project in NetBeans

Improving @JVerstry Answer.. I add Another solution unexplained here in steps.

Create a new Maven project in Netbeans. Then copy paste your source code in your maven folder, it can be done in Netbeans IDE Projects View Itself. After this follow these steps.

  1. Add SPRING MVC Dependencies.
  2. Add Spring MVC Version to your properties section (Dependent on point 1)
  3. Configure dispatcher-servlet.xml and web.xml in your Spring Folder.
  4. Rest is to do some matching and configuring your main Controller & JSP / HTML-Page.,
  5. check your home page by running.

Point 1:




Point 2: and add spring.version to your properties section


Point 3: Under WEB-INF folder, create a file named dispatcher-servlet.xml. Open the file and copy the following code.

<?xml version="1.0" encoding="UTF-8"?>
   <beans xmlns=""

<mvc:annotation-driven />
<context:component-scan base-package="com.youbequityweb.controllers" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/jsp/" />
    <property name="suffix" value=".jsp" />

The declares support annotation driven mvc such using @Controller, @Service, @Component.

The means to scan classes from this base package to determine all bean classes.

The view resolver specifies the locations of our views(jsp) and the extension. In your web.xml, add the spring configurations inside web-app section.

<!--Spring Config-->
<listener>    <listenerclass>org.springframework.web.context.ContextLoaderListener</listener-class>
    <servlet-  class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

Point 4: This is tricky, now Link your existing main controller to the base package defined in dispatcher-servlet.xml. e.g: shown below.

package com.youbequityweb.controllers;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

public class HomeController {

@RequestMapping(value="/home", method = RequestMethod.GET)
    public String viewHome(){
    return "home";

Point 5: In NetBeans, now right click, choose clean and build, get away if any warnings and conflicts and than run your spring mvc application for results.

I discovered by accident, the reason why Netbeans 8.2. opens projects as Netbeans projects instead of Maven projects; after you have deleted the netbeans and ant specific files then replaced them with the correctly formed pom.

Netbeans seems to cache the project types for already opened projects, this can be resolved by deleting said cache.

Windows its located here:


Linux here:


Mac here:


Need Your Help

how to control tabs current effect using javascript

javascript html css

I have html form which contains a tab menu the code is

Override file in Gradle build dependency jar

gradle build.gradle gradlew

I would like to output a jar which internally contains my dependency jar but overrides a particular file in the dependency jar with my own. I am using gradle build. Can someone help me with this? The