没有找到JAX-RS的处理程序方法

时间:2017-07-29 18:41:25

标签: java spring rest spring-boot

我有一个资源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并且没有进行任何配置。

2 个答案:

答案 0 :(得分:1)

你无缘无故地混淆技术。 Spring拥有自己的Web框架,不需要JAX-RS,Spring Web也不符合JAX-RS,这解释了为什么处理程序没有注册。见this。可以将JAX-RS与Spring依赖注入一起使用,但这是不必要的。请参阅this

答案 1 :(得分:0)

您是否在spring boot中配置jaxrs以在ProfileResource包中查找其余资源(或者至少专门注册了您的类)?

我建议您阅读here第27.2节

的春季启动文档