`

Add Java EE dependencies for Maven

阅读更多

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>
     
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics