本文介绍了Servlet 3.0 API 的 Maven 依赖?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何告诉 Maven 2 加载 Servlet 3.0 API?

How can I tell Maven 2 to load the 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/ 但是存储库是什么正确吗?

I use http://repository.jboss.com/maven2/ but what repository would be correct?

附录:

它依赖于整个 Java EE 6 API 和以下设置:

It works with a dependency for the entire Java EE 6 API and the following settings:

<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 已替换了单独的依赖项.是否有消息来源证实了这一假设?

I'd prefer to only add the Servlet API as dependency, but "Brabster" may be right that separate dependencies have been replaced by Java EE 6 Profiles. Is there a source that confirms this assumption?

推荐答案

老实说,我不确定为什么但没关系...

To be honest, I'm not sure to understand why but never mind...

Brabster 单独的依赖项已被 Java EE 6 配置文件取代.是否有消息来源证实了这一假设?

Java.net 的 maven 存储库确实为 WebProfile 提供了以下工件:

The maven repository from Java.net indeed offers the following artifact for the WebProfile:

<repositories>
  <repository>
    <id>java.net2</id>
    <name>Repository hosting the jee6 artifacts</name>
    <url>http://download.java.net/maven/2</url>
  </repository>
</repositories>
<dependencies>
  <dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-web-api</artifactId>
    <version>6.0</version>
    <scope>provided</scope>
  </dependency>
</dependencies>

这个jar包包括Servlet 3.0、EJB Lite 3.1、JPA 2.0、JSP 2.2、EL 1.2、JSTL 1.2、JSF 2.0、JTA 1.1、JSR-45、JSR-250.

This jar includes Servlet 3.0, EJB Lite 3.1, JPA 2.0, JSP 2.2, EL 1.2, JSTL 1.2, JSF 2.0, JTA 1.1, JSR-45, JSR-250.

但据我所知,没有什么可以说这些 API 不会单独分发(在 java.net 存储库或其他地方).例如(好吧,这可能是一种特殊情况),JSF 2.0 API 是单独可用的(在 java.net 存储库中):

But to my knowledge, nothing allows to say that these APIs won't be distributed separately (in java.net repository or somewhere else). For example (ok, it may a particular case), the JSF 2.0 API is available separately (in the java.net repository):

<dependency>
   <groupId>com.sun.faces</groupId>
   <artifactId>jsf-api</artifactId>
   <version>2.0.0-b10</version>
   <scope>provided</scope>
</dependency>

实际上,您可以从 并将其安装在您自己的存储库中.

And actually, you could get javax.servlet-3.0.jar from there and install it in your own repository.

这篇关于Servlet 3.0 API 的 Maven 依赖?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 19:49