Today I want to talk about Maven. It’s very powerful instrument and if you know how to use it you will make minimum effort to achieve maximum result. In general Maven helps you to manage a project including library dependencies, building process and etc… But in the article I’m going to show you one of the ways how to create a Dynamic Web Project using Maven (in Eclipse IDE).


  • Eclipse IDE for Java EE Developers
  • M2E plugin for Eclipse
  • Maven

1. File > New (Alt+Shift+N) > Dynamic Web Project

  • Input some name for the project in the “Project name” field (e.g. mavenDWP);
  • Select some “Target runtime” (I use Apache Tomcat 7.0);
  • Click on the “Next” button;
  • Create the following directory structure (please pay attention to the directory structure. It’s an important detail in the creation of Dynamic Web Project):


  • Click on the “Next” button;
  • Select the “Generate web.xml deployment descriptor” check-box;
  • Click on the “Finish” button.


2. Right click on the project > Configure > Convert to Maven Project

  • Select “Packaging” as a WAR;
  • Click on the “Finish” button;
  • After that, pom.xml will appear in the project’s structure;
  • Move all stuff from the WebContent folder to src/main/webapp;
  • WebContent folder can be deleted after that.

3. Open the project’s root folder in the file system

  • Execute the following command: mvn eclipse:eclipse -Dwtpversion=2.0
  • This command will generate a configuration for eclipse (.classpath, .project, etc.).
  • Expand src > main and make a right click on the webapp folder: Build Path > Use as Source Folder (This point is actual only if src/main/webapp disappeared from the source folders).

Here is the final view of the Dynamic Web Project configured with Maven:


That’s it. I hope this tutorial was clear enough and you will be able to set up everything described above without any problems. I will try to answer on every question in the comments.

About The Author

Mathematician, programmer, wrestler, last action hero... Java / Scala architect, trainer, entrepreneur, author of this blog

  • Fruzenshtein

    Sometimes you can get this error while setting up a Dynamic Web Project:

    CHKJ3000E: WAR Validation Failed: org.eclipse.jst.j2ee.commonarchivecore.internal.exception. DeploymentDescriptorLoadException: WEB-INF/web.xml

    In order to fix this, make right click on your project and choose “Validate”. After this action refresh the project and everything will be ok.

  • It’s much easier to install the m2e WTP integration plugin. With that, you only have to create a new Maven project with packaging type ‘war’ and everything else is done automatically.

    • Fruzenshtein

      Agree =)
      But I don’t look for the easiest ways =)

  • Yadab Raj Ojha

    You save my day! Nice clean tutorial. Thank you for this post!

  • prabakar

    awesome….thanks for for valuable time and sharing your knowledge to others…

  • siri

    I’m new to Maven, So my question is I have a dynamic web project wherein my project also contains .properities as well as .txt files. While mavenizing tis project where tis files needs to be resided. After mavenizing, the resultant war needs to be deployed.

    Will be waiting for your reply

    Thanks in advance

    • Fruzenshtein

      src/main/resources – this folder is for different configurations

  • sri

    First of all Thanks for the post
    I am new to eclipse.
    after creating a new dynamic web project am not able to find the configure option (right click of project) in eclipse.
    Can u please assist me in this regard.

    • Fruzenshtein

      Select the project in a navigator section (left side of Eclips by default), click on the “Project” item in the main menu, click on the “Properties”.


  • Jonathan García

    “Move all stuff from the WebContent folder to src/main/webapp;”

    for it is this step?

    • As soon as you created the src/main/webapp folder and added it to an application’s build path, you can move all stuff from the WebContent folder to the src/main/webapp

      • isccarrasco

        i do that…

        but always see this error…

        descripción: El recurso requerido no está disponible.

        but, if i create the WebContent/WEB-INF/page folder and put the jsp into this folder, the application run perfectly…

        can you help me??

  • my2 koseli


    So I am still new to spring MVC and I am following your examples using the annotated version of the Spring MVC.

    I want to create a sample application where I want to list all the test results that are stored in a table. I also want to present a form

    This is my sample model which I want to present in a form:

    package foo;

    import javax.persistence.AttributeOverride;



    public class TestResult {

    private string name;

    private string time;

    private string host;


    I then have a controller with following options:

    package foo;



    public class TestResultController {


    public ModelAndView listOfTeams() {

    ModelAndView modelAndView = new ModelAndView(“list-of-teams”);

    List teams = testresultService.getTeams();

    modelAndView.addObject(“teams”, teams);

    modelAndView.addObject(“filteroptions”, this.getFilterOptions());

    return modelAndView;


    public Map getFilterOptions(){

    Map filter_options = new HashMap();

    filter_options.put(“test_name”, “Test Name”);

    filter_options.put(“host”, “Host”);

    filter_options.put(“time”, “Time”);

    return filter_options;



    This is my jsp which is currently CHOKING up on me because I am not sure what I need to put first in “select path”. I am also not sure if I have the “commandName” correct. Can you please guide me?















    • Man, you are asking me to do all stuff for you
      I can’t do this
      But you can go through articles on my blog and you will see that I explain step by step how to perform everything you want

      • my2 koseli

        Hi Alex,

        I am trying to pass a column name dynamically to the query in hibernate but I have not been able to do so. Can you shed light on how to do this? I have tried Restrictions like the following:

        Restrictions.eq(option.column_name, “first_test”)).list();

        but i am getting following error: org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.QueryException: could not resolve property:

    • Alabama Mothman

      Drop Spring, go to JSF. Spring is aweful

  • Waqar

    It’s something like difficult stuff. You can create maven project simple by click on the new project select maven project and click next and fill project name accordingly. That’s it. Why this drag it needed?

  • Env

    I not understand few things and of course example not work…

    1. You create srcmainwebapp and others but on eclipse screen u have src/main/webapp. In my project i have still srcmainwebapp

    2. You create WebContent folder and copy files into src/main/webapp
    What is puprpose this? (IMO this operation not have sense beacuse u can generate here src/main/webapp)

    2.2 Why u not write about deployment assembly?

    Note for article is: 2/10
    It is waste nerves and time and another trash in interent…

  • Lisa

    Perfect! Everything went smoothly thank you very much!

    • puhspak

      tell me at which place i put index.jsp so i can run this project?

  • MTK

    if the command “mvn eclipse:eclipse” doesn’t work try to do it using eclipse,
    go to the project , right click , and Run as > run Configuration… then click on ‘build maven’, it will show a new window, brows to the project folder, and put ‘eclipse:eclipse’ in goal text zone.

    • Hitesh Sethiya

      good one dude. 🙂

  • Gracias !!

  • puhspak

    at which place i put my index.jsp so i can run this project any 1 suggest me?

    • ruksar

      you can put it in webapp

  • Nessus

    The best article i’ve seen about this subject. Its easy to understand and goes directly to the objective. Congratulations and thank you.

  • Guto Catanho

    really good. Thanks

  • Pingback: Spring MVC + Hibernate + Maven: CRUD操作示例 - Jeek()

  • Kedar

    Its really nicely explained! Thanks!!!

  • Alabama Mothman

    I new to this. I would just wish like heck Spring would just create jars with all the basic dependencies included. Or at least tell us what versions of (for instance, hibernate to use) use maven and if your not holding your mouth right none of it works. It’s hit or miss. Ive spend days just trying to get my config files(DTD’s, and versions) to match up. It’s a nightmare. There have been many times that Ive just about given up on Spring, and still not convinced of it.

    Spring MVC is not even MVC. Not if you have to still embed logic into your jsp page. JSF is vastly superior.

  • kedar

    I followed all the steps and it went perfect. Now I am trying to create .html and .jsp files under webapp, but the popup is not appearing to add in eclipse. What could be the reason for this? could you suggest please.

  • Marcel Korpel

    After converting an Eclipse dynamic web project to a Maven project, I copied everything in WebContent to src/main/webapp, but when I export a WAR file, I get a copy of WEB-INF and META-INF in /WEB-INF/classes (beside the top-level domain of my package). Moveover, there’s a directory with the project name within a directory with the project name within the maven directory. This doesn’t look like what I want.

    Please have a look at these screenshots of Eclipse and what it looks like when I unpack the resulting WAR file in /srv/http/configserver. The left pane shows the content of ./maven/configserver/configserver.

    • I’ve described too complex scenario. It shouldn’t exist according to this tutorial

      • Marcel Korpel

        Well, almost everything is correct when using Run As > Maven build… and do a ‘clean install’ to create a WAR file, I only get a double META-INF, when trying to run this project on server from within Eclipse, my index.jsp could not be found, even when I deploy src/main/webapp to / in Deployment Assembly.

        The only workaround I can see is to configure Maven to use WebContent as the web root, but that’s an ugly solution to make Eclipse work nice with Maven.

  • Pingback: Spring Data (JPA) – JUGLviv()

  • Merve Bayram

    There isn’t Dinamic Web Project under File > New (Alt+Shift+N) . I install the maven there is maven project but i cant find DWP. Are maven project and DWP same thing???? Please help me