Deploying a Maven-based web project from Eclipse

Here’s the problem: you start with a Web project in Eclipse, created via one of the Wizards. At some point you convert it to a Maven project, but when you deploy the project from Eclipse, your web content in /src/main/webapp is not deployed, because Eclipse is not aware of the Maven folder structure.

I’ve done this multiple times in the past and usually work out a way to build a ear/war and manually deploy it to my server or via a script instead, because I can’t work out how to get a converted project to deploy in Eclipse 🙂

The magic to get this to work is to add the maven-war-plugin to your Maven pom.xml file:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.3</version>
    <configuration>
        <failOnMissingWebXml>false</failOnMissingWebXml>
    </configuration>
</plugin>

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.