簡體   English   中英

找不到使用JAX-RS的處理程序方法

[英]Did not find handler method with JAX-RS

我有一個資源JAX-RS

@Path("/profile")
public class ProfileResource {

    @GET
    @Path(value = "/{username}")
    public Response getProfile(
            @PathParam("username") String username,
            @Context UriInfo uriInfo
    ) throws URISyntaxException {
       ....
    }
}



    2017-07-29 20:37:41.940 DEBUG 4004 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet        : Successfully completed request
2017-07-29 20:38:01.223 DEBUG 4004 --- [nio-8080-exec-7] o.s.web.servlet.DispatcherServlet        : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/profile/jonki]
2017-07-29 20:38:01.236 DEBUG 4004 --- [nio-8080-exec-7] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /profile/jonki
2017-07-29 20:38:01.236 DEBUG 4004 --- [nio-8080-exec-7] s.w.s.m.m.a.RequestMappingHandlerMapping : Did not find handler method for [/profile/jonki]
2017-07-29 20:38:01.237 DEBUG 4004 --- [nio-8080-exec-7] o.s.w.s.handler.SimpleUrlHandlerMapping  : Matching patterns for request [/profile/jonki] are [/**]
2017-07-29 20:38:01.237 DEBUG 4004 --- [nio-8080-exec-7] o.s.w.s.handler.SimpleUrlHandlerMapping  : URI Template variables for request [/profile/jonki] are {}
2017-07-29 20:38:01.237 DEBUG 4004 --- [nio-8080-exec-7] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapping [/profile/jonki] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/], class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@36463b09]]] and 1 interceptor
2017-07-29 20:38:01.237 DEBUG 4004 --- [nio-8080-exec-7] o.s.web.servlet.DispatcherServlet        : Last-Modified value for [/profile/jonki] is: -1
2017-07-29 20:38:01.238 DEBUG 4004 --- [nio-8080-exec-7] o.s.web.servlet.DispatcherServlet        : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
2017-07-29 20:38:01.238 DEBUG 4004 --- [nio-8080-exec-7] o.s.web.servlet.DispatcherServlet        : Successfully completed request
2017-07-29 20:38:01.238 DEBUG 4004 --- [nio-8080-exec-7] o.s.web.servlet.DispatcherServlet        : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/error]
2017-07-29 20:38:01.239 DEBUG 4004 --- [nio-8080-exec-7] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /error

我找不到使用JAX-RS的方法。 我正在使用Spring Boot,還沒有做任何配置。

您無緣無故混搭技術。 Spring有其自己的Web框架,不需要JAX-RS,而且Spring Web也不兼容JAX-RS,這解釋了為什么未注冊處理程序。 看到這個 可以將JAX-RS與Spring依賴項注入一起使用,但這不是必需的。 看到這個

您是否已在Spring Boot中配置jaxrs以在ProfileResource包中查找其余資源(或至少專門注冊了您的類)?

我建議您第27.2節中閱讀有關此問題的Spring Boot文檔

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM