RestEasyClientBuild register ResteasyJackson2Provider - WARN about duplicate
I had the same issue, but I did not want to remove the resteasy-jackson2-provider
dependencies because we added that dependency explicitly for other parts of the system (using undertow, not full AS).
Turns out you can just extend the org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider
without adding/overriding anything so you can register it with a higher priority than the default org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider
picked up from the classpath (which is registered without a priority). This way you ensure your ResteasyJackson2Provider
will be chosen over the one picked up via classpath scanning.
Extending to a "custom" ResteasyJackson2Provider
:
public class CustomResteasyJackson2Provider extends ResteasyJackson2Provider {
}
Plug that in to the ResteasyClientBuilder with your customized ObjectMapper:
ObjectMapper objectMapper = new ObjectMapper();
// customize your objectMapper here...
CustomResteasyJackson2Provider jacksonProvider = new CustomResteasyJackson2Provider();
jacksonProvider.setMapper(objectMapper); // add objectMapper to provider
// register provider to client
ResteasyClient client = new ResteasyClientBuilder()
.register(jacksonProvider, 100) // any priority over 0 will do
.build();
Hope this helps.