简体   繁体   English

在Jersey分辨率中生成媒体类型冲突错误

[英]Producing media type conflict error in Jersey resolution

I have these 2 methods below defined in my restful resource class. 我在restful资源类中定义了以下两种方法。 I'm using Jersey. 我正在使用泽西岛。 But when I try to run a unit it says error, they have the same media type. 但是,当我尝试运行一个单位时,它说错误,它们具有相同的媒体类型。 Am I missing something ? 我错过了什么吗?

SEVERE: The following errors and warnings have been detected with resource and/or provider classes: SEVERE: Producing media type conflict. 严重:已使用资源和/或提供程序类检测到以下错误和警告:严重:生成媒体类型冲突。 The resource methods public javax.ws.rs.core.Response com.thomsonreuters.codes.sourcedocweb.resource.DocumentsResource.findDocumentMetadataByCorId(java.lang.String) and public javax.ws.rs.core.Response com.thomsonreuters.codes.sourcedocweb.resource.DocumentsResource.findDocumentMetadata(java.lang.String) can produce the same media type Feb 11, 2013 5:43:56 PM com.sun.jersey.test.framework.spi.container.inmemory.InMemoryTestContainerFactory$InMemoryTestContainer stop INFO: Stopping low level InMemory test container 资源方法public javax.ws.rs.core.Response com.thomsonreuters.codes.sourcedocweb.resource.DocumentsResource.findDocumentMetadataByCorId(java.lang.String)和public javax.ws.rs.core.Response com.thomsonreuters.codes。 sourcedocweb.resource.DocumentsResource.findDocumentMetadata(java.lang.String)可以生成相同的媒体类型2013年2月11日下午5:43:56 com.sun.jersey.test.framework.spi.container.inmemory.InMemoryTestContainerFactory $ InMemoryTestContainer stop信息:停止低级InMemory测试容器

@GET
@Path("/{docId}/metadata")
@Produces(MediaType.APPLICATION_XML)
public Response findDocumentMetadata(@PathParam("docId")
final String docId)
{
    Response response = findMetadataForDocument(docId);

    return response;
}


@GET
@Path("/{corid}/metadata")
@Produces(MediaType.APPLICATION_XML)
public Response findDocumentMetadataByCorId(@PathParam("corid")
final String corid)
{
    Response response = findMetadataForDocument(corid);

    return response;
}

The first thing I notice is that the two paths will conflict. 我注意到的第一件事是两条路径会发生冲突。 Jersey doesn't have any frame of reference to know if /1/metadata should be routed to the first or second method. Jersey没有任何参考框架可以知道/ 1 /元数据是否应该路由到第一种或第二种方法。 You might try defining your paths as /doc/metadata/{docid} and /cor/metadata/{corid}. 您可以尝试将路径定义为/ doc / metadata / {docid}和/ cor / metadata / {corid}。 Hope this helps. 希望这可以帮助。

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

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