You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to register a new module into the object mapper present in Jackson2JsonMessageConverter, but the documentation suggests two ways of doing it:
One is to configure the ObjectMapper and inject into Jackson2JsonMessageConverter. The documentation in the setJsonObjectMapper suggest an alternative which is to extend the class and override the method initializeJsonObjectMapper
The issue with extending the Jackson2JsonMessageConverter is the lack of access to the ObjectMapper in the parent class, ending up like this:
public class JacksonMessageConverter extends Jackson2JsonMessageConverter {
@Override
protected void initializeJsonObjectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new GuavaModule());
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
this.setJsonObjectMapper(objectMapper);
}
}
So we still have to inject the ObjectMapper, besides overriding the method, it doesn't really look like an alternative.
Changing the ObjectMapper visibility to protected (or a getter) would give us the alternative.
The text was updated successfully, but these errors were encountered:
Fixes#589
* Deprecate `setJsonObjectMapper()` in favor of newly introduced ctor
based on the external `ObjectMapper`
* Deprecate `initializeJsonObjectMapper()` in favor of newly introduced
ctor based on the externally configured `ObjectMapper`
Fixes#589
* Deprecate `setJsonObjectMapper()` in favor of newly introduced ctor
based on the external `ObjectMapper`
* Deprecate `initializeJsonObjectMapper()` in favor of newly introduced
ctor based on the externally configured `ObjectMapper`
I want to register a new module into the object mapper present in Jackson2JsonMessageConverter, but the documentation suggests two ways of doing it:
One is to configure the ObjectMapper and inject into Jackson2JsonMessageConverter. The documentation in the setJsonObjectMapper suggest an alternative which is to extend the class and override the method initializeJsonObjectMapper
The issue with extending the Jackson2JsonMessageConverter is the lack of access to the ObjectMapper in the parent class, ending up like this:
So we still have to inject the ObjectMapper, besides overriding the method, it doesn't really look like an alternative.
Changing the ObjectMapper visibility to protected (or a getter) would give us the alternative.
The text was updated successfully, but these errors were encountered: