adam bien's blog

A Minimalistic POM For JavaEE 6/7 📎

The essential pom for JavaEE projects is < 40 lines of xml:


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.airhacks</groupId>
    <artifactId>javaee-essentials-pom</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

The war plugin has only has to be added to make web.xml optional :-). If you need a web.xml (for JAX-RS or Servlets web.xml is not needed), you can remove the war plugin as well.

The pom.xml was also checked-in into: https://github.com/AdamBien/javaee-essentials-pom

If you are planning to write tests (:-)), you should replace the javaee-web-api dependency with an actual server implementation.

See you at Java EE Workshops at MUC Airport (Maven is discussed in the "Effective JavaEE" workshop)!