Using Jackson as Jersey client serializer

后端 未结 6 1947
暖寄归人
暖寄归人 2021-01-30 13:23

Is it possible to use Jackson as the serializer/marshaller for JSON data instead of JAXB when using Jersey Client API?

If so how to configure it?

6条回答
  •  深忆病人
    2021-01-30 14:09

    OK, I found it out, it turns out to be quite simple after all:

    ClientConfig cc = new DefaultClientConfig();
    cc.getClasses().add(JacksonJsonProvider.class);
    Client clientWithJacksonSerializer = Client.create(cc);
    

    The JacksonJsonProvider comes from the jackson-jaxrs package.

提交回复
热议问题