From 4eeef2fee19a5ff0cdb940486fee3b8107bb32e3 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Tue, 20 Dec 2016 12:51:01 +0100 Subject: [PATCH] DATAREST-899 - Prefer user registered modules over default ones. We now issue the user registration of Jackson modules before any of the default modules Spring Data registers get applied. Testing module registration seems to be rather difficult as Jackson doesn't actually expose API to do so. An issue [0] was filed for Jackson to improve on this. [0] https://github.com/FasterXML/jackson-databind/issues/1478 --- .../rest/webmvc/config/RepositoryRestMvcConfiguration.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.java index fae81cc3f..5858db77d 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.java @@ -828,6 +828,10 @@ public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebCon objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true); objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + // Configure custom Modules + configurerDelegate.configureJacksonObjectMapper(objectMapper); + objectMapper.registerModule(geoModule); if (config().isEnableEnumTranslation()) { @@ -835,8 +839,6 @@ public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebCon } Jackson2DatatypeHelper.configureObjectMapper(objectMapper); - // Configure custom Modules - configurerDelegate.configureJacksonObjectMapper(objectMapper); return objectMapper; }