It would be great, if RestClient followed the spring.mvc.converters.preferred-json-mapper=gson
setting or had a similar own. Now it only checks the classpath for the existence of jackson classes (in DefaultRestClientBuilder.initMessageConverters()
). Since my application includes spring-boot-starter-actuator
jackson will always be on the classpath, so there is no way RestClient will create GsonHttpMessageConverter
instead of MappingJackson2HttpMessageConverter
. As a workaround we can pass HttpMessageConverter
s from application context to RestClient.Builder
, but DefaultRestClientBuilder.initMessageConverters()
creates more converters, than I have in context. It seems, I don't need them, but I haven't tested it properly.
Comment From: snicoll
@rufus20145 the behavior you've described (and the property) is happening in Spring Boot, not Spring Framework. Moving.
Comment From: wilkinsona
This is related to https://github.com/spring-projects/spring-boot/issues/33870#issuecomment-2422737522 where we were also wondering about a property for choosing Gson that isn't specific to MVC.