WellaceZ opened a new issue #1541: 重写返回值序列化,工程启动报LinkageError
URL: https://github.com/apache/servicecomb-java-chassis/issues/1541
 
 
   
业务需要REST返回值支持compactFormat和PrettyPrint两种输出格式,因此重写了ProduceJsonProcessor。但是工程启动却报LinkageError错误。如何解决?
   (1)自定义的ProduceProcessor实现类如下:
   public class MyProduceProcessor implements ProduceProcessor {
   
       @Override
       public String getName() {
           return String.valueOf(MediaType.APPLICATION_JSON);
       }
   
       @Override
       public int getOrder() {
           return -1;
       }
   
       @Override
       public void doEncodeResponse(OutputStream outputStream, Object o) throws 
Exception {
           
RestObjectMapperFactory.getRestObjectMapper().writerWithDefaultPrettyPrinter().writeValue(outputStream,
 o);
       }
   
       @Override
       public Object doDecodeResponse(InputStream inputStream, JavaType 
javaType) throws Exception {
           return 
RestObjectMapperFactory.getRestObjectMapper().readValue(inputStream, javaType);
       }
   }
   (2)自定义的ProduceProcessor实现类如下:

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to