Search code examples
javaeclipsemavenm2eclipse

Converting Eclipse Maven Project into Eclipse Maven Dynamic Web Project


I need to convert my java maven project in eclipse into a maven dynamic web project. My project is connected to an mercurial repository, so simply deleting and creating a new project is not an option!

My project strucutre is:

project
    - src/main/java
    - src/main/resources
    - src/test/java
    - src/test/resources
    - pom.xml

I have to change the project type to a dynamic web project without deleting my present project.


Solution

  • Simply add the packaging type war to your POM.

    <project ...>
        ...
        <packaging>war</packaging>
        ...
    </project>
    

    Then let the m2e plugin update your project. (Rightclick project -> Maven -> Update project...) The m2e plugin now rewrites the project meta-files (.project and .classpath, as well as files in the .settings folder). That's it. Now you have a web project.