Add Java EE dependencies for Maven 2  

Joined:
08/13/2009
Posts:
172

September 19, 2009 21:16:52    Last update: March 02, 2010 05:13:04
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.
  1. 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>
    


  2. 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>
    

Share |
| Comment  | Tags