Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/390.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我';我没有运行jersey 2 web服务?_Java_Apache_Jersey_Jersey 2.0 - Fatal编程技术网

Java 我';我没有运行jersey 2 web服务?

Java 我';我没有运行jersey 2 web服务?,java,apache,jersey,jersey-2.0,Java,Apache,Jersey,Jersey 2.0,我创建了一个动态java项目并添加了此依赖项: <!-- https://mvnrepository.com/artifact/org.glassfish.jersey.containers/jersey-container-servlet-core --> <dependency> <groupId>org.glassfish.jersey.containers</groupId>

我创建了一个动态java项目并添加了此依赖项:

<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.containers/jersey-container-servlet-core -->
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet-core</artifactId>
            <version>2.23.1</version>
        </dependency>
在App类所在的包中,我创建了以下内容:

@Path("restaurantAPI")
public class RestaurantAPI {

    @Path("/get")
    @GET
    public Response getRequest(@PathParam("id") String id) {
        return Response.ok(id).build();
    }

}
我运行我的服务器,并将此URL称为:

http://localhost:8080/ULTestServer/test/restaurantAPI/get?id=3
但我得到错误404

请问我错过了什么?(我总是这样做,而且它过去也很管用)

改变

jersey-container-servlet-core

原因是后者的1允许在不使用web.xml的情况下发现应用程序,以替换
@ApplicationPath
。这是Servlet3可插拔机制的一部分

第一个依赖项用于非servlet 3.0容器,其中必须使用web.xml来注册servlet


1-

jersey-container-servlet-core
jersey-container-servlet