问题描述
如何告诉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>
我使用但是哪个存储库是正确的?
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配置文件已替换了单独的依赖项。是否有确认此假设的来源?
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...
来自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>
实际上,你可以得到 javax.servlet-3.0.jar 并安装在你自己的存储库。
And actually, you could get
javax.servlet-3.0.jar
from there and install it in your own repository.
这篇关于Servlet 3.0 API的Maven依赖?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!