繁体   English   中英

Apache-CXF JAX-RS实现不遵守正确的@Path顺序

[英]Apache-CXF JAX-RS implementation not respecting proper @Path ordering

我有一个看起来像这样的JAX-RS Web服务:

@Path("/service")
public interface Service {
    @GET
    @Path("/{serviceId}")
    public Response getService(@PathParam("serviceId") String serviceId);

    @GET
    @Path("/{serviceId}/private")
    public Response getPrivateService(@PathParam("serviceId") String serviceId);

    @GET
    @Path("/other-thing")
    public Response getOtherThing(@CookieParam("cookieName") String cookieValue);
}

由于某些原因, GET /other-thing始终使用@Path("/{serviceId}")调用第一个方法。 调用GET /abc/private返回404,声称没有匹配的路由。 根据规范,应该选择文字字符最匹配的路径,但是好像我的路线被完全忽略了。 我该如何调试?

这是来自CXF的日志消息:

No operation matching request path "/service/abc/private" is found, Relative Path: /abc/private, HTTP Method: GET, ContentType: */*, Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8,. Please enable FINE/TRACE log level for more details.

我发现了问题。

我最近从Eclipse切换到IntelliJ。 Eclipse的默认行为是在自动生成接口方法实现时忽略任何注释。 另一方面,IntelliJ保留注释。 这是不同的:

// In Eclipse
public class ServiceImplementation implements Service {
    public Response getService(String serviceId) {
        return null;
    }
}

// In IntelliJ
public class ServiceImplementation implements Service {
    // Note the @PathParam
    public Response getService(@PathParam("serviceId") String serviceId) {
        return null;
    }
}

服务实现中的附加注释会导致路径解析失败。 由于我已经在Eclipse中实现了getService ,因此它可以正常工作,但是实现IntelliJ的新方法在我删除了服务实现中的参数注释后才起作用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM