spring-projects / spring-modulith

Modular applications with Spring Boot
https://spring.io/projects/spring-modulith
Apache License 2.0
716 stars 113 forks source link

Java 8 date/time type `java.time.Instant` not supported by default #563

Open thestroke82 opened 2 months ago

thestroke82 commented 2 months ago

The serializer needs datatype-jsr310. I apologize in advance if it's already been reported.

odrotbohm commented 2 months ago

I am assuming you're referring to the Jackson ObjectMapper used to serialize the event instances? That one is picked up from Boot's default setup. The fallback we declare picks up all Module beans from the ApplicationContext. In other words, if the JSR-310 module is on the classpath it should be registered through Boot.

If that doesn't work, would you mind creating a minimal reproducer for us to investigate?

thestroke82 commented 2 months ago

Yes I am referring to the Jackson ObjectMapper. In fact jackson-datatype-jsr310 was already present in the classpath, but i still got the error. I'll try to reproduce it but really it was no special configuration: some standard Boot starters, js310 and spring-modulith-events-api. I get the error when I try to publish an event.

odrotbohm commented 2 months ago

You might want to debug into JacksonEventSerializationConfiguration.jacksonEventSerializer(…) and see whether the ObjectProvider contains a preconfigured instance.