How to config maven to use servlet 3

痴心易碎 提交于 2020-01-02 00:55:14

问题


I want to upgrade my webapp to use servlet 3.0 (insetd of 2.5). I am using WebLogic Server Version: 12.1.1.0 (12c),maven,java 7_10 and NetBeans 7.3.1

For some reason the only available servlet-api is 3.0-alpha-1 and not 3.0

<project xmlns="http://maven.apache.org/POM/4.0.0"      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>3.0-alpha-1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.myfaces.core</groupId>
        <artifactId>myfaces-api</artifactId>
        <version>2.1.8</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.myfaces.core</groupId>
        <artifactId>myfaces-impl</artifactId>
        <version>2.1.8</version>
        <scope>compile</scope>
    </dependency>

回答1:


Your options are actually 3.0.1 or 3.1.0 of the final releases, and the artifact ID has been changed. Using the old servlet-api artifact ID, the releases available are only 2.x, aside from the alpha you've found.

If you update to javax.servlet-api, you'll find the newer 3.x releases:

http://mvnrepository.com/artifact/javax.servlet/javax.servlet-api

You can update your POM to use:

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.0.1</version>
    <scope>provided</scope>
</dependency>



回答2:


Try this dependency

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
</dependency>

found here: http://mvnrepository.com/artifact/javax.servlet/javax.servlet-api

There is also a version 3.0.1 if you need something closer to 3.0



来源:https://stackoverflow.com/questions/24855531/how-to-config-maven-to-use-servlet-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!