On Fri, Jul 10, 2020 at 8:29 PM 이동권 <[email protected]> wrote:
>
>
> I don't know well, Post a question.
> I used Jackson Json Libraries with SpringBoot
>
> When i use @JsonSerialize(using = CustomSerializer.class) in severals POJO 
> class Field
>
> CustomSerializer has no-args constructor with "initialized" logging command
> Jackson create Serializer instance for Each POJO class on Json Serialize 
> Process.
>
> how can i create Serializer single instance, and share this.
>
> is it right thinking?

When using `JsonSerializer(using = )`, a new instance will be created
for every POJO type, correct.

If you would like to use one serializer instance for multiple types,
you should instead register serializers using `Module`.
For example, using `SimpleModule`:

-----
SimpleModule module = new SimpleModule();
module.addSerializer(Type1.class, serializerInstance);
module.addSerializer(Type2.class, serializerInstance);
ObjectMapper mapper = JsonMapper.builder().
    .addModule(module)
    .build();
-----

I hope this helps

-+Tatu +-

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jackson-user/CAL4a10gROcQLGuHR0b_FVoyECU1MH_y9yuNXwYhQwrZcwHG%2BxQ%40mail.gmail.com.

Reply via email to