2016-06-21 1 views
2

는 I 동적 자바 프로젝트를 생성하고이 종속성 첨가 :이 같은 애플리케이션 클래스 생성이어서저지 2 웹 서비스를 실행하는 데 실종 된 점은 무엇입니까?

<!-- 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> 

을 :

@ApplicationPath("/test") 
public class App extends ResourceConfig { 
    public App() { 
     this.packages("com.test.ul"); 
    } 
} 

을 상기 애플리케이션 클래스에있는 동일한 패키지 내가 만들어 이 :

@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 

jersey-container-servlet 

에 이유는 후자가없이 응용 프로그램을 발견을 허용 required component 1을 가지고 있다는 것입니다

답변

1

변경 (난 항상 그렇게하고 그것은 작동하는 데 사용) web.xml은 @ApplicationPath을 대체합니다. 이것은 서블릿 3 플러그인 메커니즘의 일부입니다.

첫 번째 종속성은 서블릿 3.0이 아닌 컨테이너에 사용되며 이 있으면 Jersey 서블릿을 등록하기 위해 web.xml을 사용합니다.


1-Here is the implementation

관련 문제