如何告诉Maven 2加载Servlet 3.0 API?
我试着:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0</version>
<scope>provided</scope>
</dependency>
我使用http://repository.jboss.com/maven2/,但是哪种存储库是正确的?
附录:
它与整个Java EE 6 API和以下设置的依赖项一起工作:
<repository>
<id>java.net</id>
<url>http://download.java.net/maven/2</url>
</repository>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
我更倾向于只添加Servlet API作为依赖项,但“Brabster”可能是正确的,单独的依赖项已被Java EE 6 Profiles取代。有消息来源证实这一假设吗?
下面演示了一种包含Java EE 6依赖项的方便方法(推荐使用JBoss)。因此,依赖关系是分开放置的(不像javaee-web-api那样全部放在一个jar中),库的源文件和javadocs可以从maven存储库中下载。
<properties>
<jboss.javaee6.spec.version>2.0.0.Final</jboss.javaee6.spec.version>
</properties>
<dependencies>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-web-6.0</artifactId>
<version>${jboss.javaee6.spec.version}</version>
<scope>provided</scope>
<type>pom</type>
</dependency>
</dependencies>
要只包含单个依赖项,可以使用dependencyManagement节和作用域导入:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee6-specs-bom</artifactId>
<version>${jboss.javaee6.spec.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- No need specifying version and scope. It is defaulted to version and scope from Bill of Materials (bom) imported pom. -->
<dependency>
<groupId>org.jboss.spec.javax.servlet</groupId>
<artifactId>jboss-servlet-api_3.0_spec</artifactId>
</dependency>
</dependencies>