更改JsonProperty以便分别获取和张贴的方法

时间:2018-12-25 08:54:33

标签: java rest get swagger put

我们有一个带有联系人列表的聚会,该聚会在运行时会更改以获取和发布。需要一种方法来分别指定GET / POST的范围。其他人没有列出的解决方案

    [qtp1250112917-62] INFO  com.netflix.dyno.queues.redis.RedisDynoQueue  - com.netflix.dyno.queues.redis.RedisDynoQueue is ready to serve task_10001
    50110 [main] INFO  com.netflix.conductor.jetty.server.JettyServer  - Ephemeral Kitchen sink workflow with ephemeral tasks is created!
    60101 [qtp1250112917-61] ERROR com.netflix.conductor.server.resources.WebAppExceptionMapper  - Error NotFoundException url: 'index.html'
    com.sun.jersey.api.NotFoundException: null for uri: http://localhost:8080/index.html
            at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1543)
            at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473)
            at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)
            at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)
            at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)
            at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558)
            at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
            at com.google.inject.servlet.ServletDefinition.doServiceImpl(ServletDefinition.java:286)
            at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:276)
            at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:181)
            at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:91)
            at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:85)
            at com.netflix.conductor.server.JerseyModule$1.doFilter(JerseyModule.java:83)
            at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
            at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:120)
            at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:135)
            at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1676)
            at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:581)
            at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1174)
            at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)
            at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1106)
            at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
            at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
            at org.eclipse.jetty.server.Server.handle(Server.java:524)
            at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:319)
            at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:253)
            at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273)
            at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
            at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)
            at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303)
            at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148)
            at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136)
            at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
            at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)
            at java.lang.Thread.run(Thread.java:748)

    Dec 24, 2018 9:36:36 AM com.sun.jersey.spi.container.ContainerResponse write
    SEVERE: A message body writer for Java class java.util.LinkedHashMap, and Java type class java.util.LinkedHashMap, and MIME media type application/octet-stream was not found.
    The registered message body writers compatible with the MIME media type are:
    */* ->
      com.sun.jersey.core.impl.provider.entity.FormProvider
      com.sun.jersey.core.impl.provider.entity.StringProvider
      com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
      com.sun.jersey.core.impl.provider.entity.FileProvider
      com.sun.jersey.core.impl.provider.entity.InputStreamProvider
      com.sun.jersey.core.impl.provider.entity.DataSourceProvider
      com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General
      com.sun.jersey.core.impl.provider.entity.ReaderProvider
      com.sun.jersey.core.impl.provider.entity.DocumentProvider
      com.sun.jersey.core.impl.provider.entity.StreamingOutputProvider
      com.sun.jersey.core.impl.provider.entity.SourceProvider$SourceWriter
      com.sun.jersey.server.impl.template.ViewableMessageBodyWriter
      com.sun.jersey.json.impl.provider.entity.JSONJAXBElementProvider$General
      com.sun.jersey.json.impl.provider.entity.JSONArrayProvider$General
      com.sun.jersey.json.impl.provider.entity.JSONObjectProvider$General
      com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider
      com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General
      com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General
      com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$General
      com.sun.jersey.json.impl.provider.entity.JSONListElementProvider$General
    application/octet-stream ->
      com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
      com.sun.jersey.core.impl.provider.entity.FileProvider
      com.sun.jersey.core.impl.provider.entity.InputStreamProvider
      com.sun.jersey.core.impl.provider.entity.DataSourceProvider
      com.sun.jersey.core.impl.provider.entity.StreamingOutputProvider`

对于POST,它应该类似于

Party{
    String Name;
    Contents<Contact> contacts;
}

Contact{
    String zipcode;
    String address;
}

Contents extends ArrayList{
    int totalPages;
    int pagesLeft;
    int pageSize;
}


Party{
    String Name;
    Contents<Contact> contacts; // this should change at run time
} 

对于Get,它应该类似于

Party{
    String Name;
    @JsonProperty(List<Contact>)
    Contents<Contact> contacts; // this should change at run time
}

0 个答案:

没有答案