-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backport GenericJackson2JsonRedisSerializer.configure(…)
to 3.1.x
#2722
Comments
From your code snippet above, it is not apparent what aspects of Jackson's
It is apparent that you are duplicating the logic from this constructor, but are allowing the You can accomplish this another way, if you do not need the
Simply do the following: @Configuration
class MyApplicationRedisConfiguration {
@Bean
GenericJackson2JsonRedisSerializer jsonRedisSerializer(
@Value("${spring.redis.serialization.class-property-type-name}") String classPropertyTypeName) {
GenericJackson2JsonRedisSerializer jsonRedisSerializer =
new GenericJackson2JsonRedisSerializer(classPropertyTypeName);
jsonRedisSerializer.configure(objectMapper -> {
// add ObjectMapper customizations here
});
return jsonRedisSerializer;
}
} Additionally, your "jsonRedisSerializer" I demonstrated such an injection with the |
GenericJackson2JsonRedisSerializer
constructor for custom ObjectMapper
with default setup
I needed not the one in Spring container but one with jsr310 module added. When I debugged, objectmapper that is newly made in |
Hi @roeniss - Right, I was also wondering the version of the Spring (Boot/Data) BOM you had in play. Thank you for sharing that information. I always base my answers on the latest bits if not otherwise specified. Anyway, I will talk to the team about potentially back porting this method ( |
Thank you so much! Farewell. |
@mp911de & @christophstrobl - I propose we (minimally) back port the Thoughts? |
GenericJackson2JsonRedisSerializer
constructor for custom ObjectMapper
with default setupGenericJackson2JsonRedisSerializer.configure(…)
to 3.1.x
As this change ( |
GenericJackson2JsonRedisSerializer(ObjectMapper mapper)
constructor removes the chance to apply setup inGenericJackson2JsonRedisSerializer(@Nullable String classPropertyTypeName)
.Currently I managed to make copy of
GenericJackson2JsonRedisSerializer.TypeResolverBuilder
like this:original in the comment means this: https://github.com/spring-projects/spring-data-redis/blob/main/src/main/java/org/springframework/data/redis/serializer/GenericJackson2JsonRedisSerializer.java#L381
I hope there's a more simple way to do this.
The text was updated successfully, but these errors were encountered: