Skip to content

Commit 20c3856

Browse files
committed
readme: note about registering the Jackson Modules in Spring
1 parent 0720a88 commit 20c3856

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,17 @@ This also simplifies usage on every other place, where Hibernate might need to r
291291
292292
This library provides `ObjectBigIntIdJacksonModule` and `ObjectUuidJacksonModule`, which can be registered automatically via the standard `java.util.ServiceLoader` mechanism, or explicitly.
293293
294+
Please note that in Spring, the instance of Jackson's `ObjectMapper` used for (de)serializing requests and responses of controllers by default ignores the modules provided via `ServiceLoader`,
295+
so to make it work, you have to either register the modules as beans, or add the following customizer:
296+
297+
```java
298+
@Bean
299+
public Jackson2ObjectMapperBuilderCustomizer enableServiceLoaderModules()
300+
{
301+
return builder -> builder.findModulesViaServiceLoader(true);
302+
}
303+
```
304+
294305
## Usage: (de)serialization with Gson
295306

296307
This library provides `ObjectBigIntIdTypeAdapterFactory` and `ObjectUuidTypeAdapterFactory`, which can be registered automatically via the standard `java.util.ServiceLoader` mechanism, or explicitly.

0 commit comments

Comments
 (0)