用@beanparam替换@queryparam(“”)

时间:2015-02-27 19:16:10

标签: java rest cxf jax-rs swagger

在我的一个GET服务方法中,我目前有一个用@queryparam注释的复杂对象。

public class ServiceClass
{   
@GET
public ResponseClass exampleMethod(@QueryParam("") complexobject compObj)
{...}
}

当我用@beanparam更改@queryparam(“”),并在complexobject中注释a字段时:

public class ServiceClass
{   
@GET
public ResponseClass exampleMethod(@BeanParam complexobject compObj)
{...}
}



import javax.ws.rs.*;

public class complexobject
{ @queryparam("field1")
  private String field1;
  ...getters and setters...
}

我遇到了这个问题

java.lang.AbstractMethodError: javax.ws.rs.core.Response.getStatusInfo()Ljavax/ws/rs/core/Response$StatusType;
javax.ws.rs.WebApplicationException.computeExceptionMessage(WebApplicationException.java:205)
javax.ws.rs.WebApplicationException.<init>(WebApplicationException.java:179)
javax.ws.rs.WebApplicationException.<init>(WebApplicationException.java:244)
javax.ws.rs.WebApplicationException.<init>(WebApplicationException.java:133)
org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBody(JAXRSUtils.java:1051)
org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:615)
org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:579)
org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:238)
org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:89)
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:207)
org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:209)
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:152)
org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:114)
org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:185)
org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:113)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:164)

以及

WARN JAXRSUtils:1050 - No message body reader has been found for request class complexobject, ContentType : */*.

这是为了与已经可用的API进行大范围的集成。我必须将@queryparam(“”)更改为@beanparam的原因是因为在生成Json时它只是注释复杂对象,但是我需要一种方法让用户知道这个对象中的字段以及它们可以的方式输入这些字段的值。任何帮助将非常感激。感谢。

0 个答案:

没有答案