JAXRS client can't find message body writer

后端 未结 3 1436
旧时难觅i
旧时难觅i 2020-12-06 21:29

I have a jaxrs client configured like this:



        
相关标签:
3条回答
  • 2020-12-06 22:07

    If you are using Jackson JSON library you need to add these xml tags to your application context.

    <jaxrs:providers>
    <bean id="jacksonProvider" class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" />
    </jaxrs:providers>
    

    If you are using any other library add that bean to the providers tag. Hope that helps!

    0 讨论(0)
  • 2020-12-06 22:08

    This answers point me in the right direction, yet i had to add on two parts to make it work on web.xml

     <init-param>
            <param-name>jaxrs.providers</param-name>
            <param-value>
                org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider
                (writeXsiType=false)
            </param-value>
        </init-param>
    

    And on the client call:

    List<Object> providers = new ArrayList<>();
        // add custom providers if any
        providers.add(new JacksonJaxbJsonProvider());
        WebClient client = WebClient.create(ENDPOINT_ADDRESS,providers);
    
    0 讨论(0)
  • 2020-12-06 22:15

    If you are consuming using javax.ws.rs.client.Client, please register the provider using client.register(new JacksonJsonProvider());

    0 讨论(0)
提交回复
热议问题