Before you can build a Java EE project with Maven, you need to add the Java EE dependencies. And you need to tell Maven where to find the repositories for the Java EE artifacts.
- For JDK 5 & Java EE 5:
~/.m2/settings.xml
:<?xml version="1.0" encoding="UTF-8"?> <settings> <profiles> <profile> <id>DefaultProfile</id> <activation> <activeByDefault>true</activeByDefault> </activation> <repositories> <repository> <id>maven2-repository.dev.java.net</id> <name>Java.net Repository for Maven</name> <url>http://download.java.net/maven/1/</url> <layout>legacy</layout> </repository> </repositories> </profile> </profiles> </settings>
pom.xml
:<dependencies> <dependency> <groupId>javaee</groupId> <artifactId>javaee-api</artifactId> <version>5</version> <scope>provided</scope> </dependency> </dependencies>
- For JDK 6 & Java EE 6:
~/.m2/settings.xml
:<?xml version="1.0" encoding="UTF-8"?> <settings> <profiles> <profile> <id>DefaultProfile</id> <activation> <activeByDefault>true</activeByDefault> </activation> <repositories> <repository> <id>maven2-repository.dev.java.net</id> <name>Java.net Repository for Maven</name> <url>http://download.java.net/maven/2/</url> <layout>default</layout> </repository> </repositories> </profile> </profiles> </settings>
pom.xml
:<dependencies> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>6.0-SNAPSHOT</version> <scope>provided</scope> </dependency> </dependencies>