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 e2b02c2a6..1a1d6b318 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 @@ -214,7 +214,7 @@ public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebCon ProjectionDefinitionConfiguration configuration = new ProjectionDefinitionConfiguration(); - for (Class projection : getProjections()) { + for (Class projection : getProjections(repositories())) { configuration.addProjection(projection); } @@ -429,7 +429,9 @@ public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebCon @Bean public ObjectMapper halObjectMapper() { - HalHandlerInstantiator instantiator = new HalHandlerInstantiator(getDefaultedRelProvider(), curieProvider); + RelProvider defaultedRelProvider = this.relProvider != null ? this.relProvider : new EvoInflectorRelProvider(); + + HalHandlerInstantiator instantiator = new HalHandlerInstantiator(defaultedRelProvider, curieProvider); ObjectMapper mapper = basicObjectMapper(); mapper.registerModule(persistentEntityJackson2Module()); @@ -518,7 +520,7 @@ public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebCon * * @return */ - private Module persistentEntityJackson2Module() { + protected Module persistentEntityJackson2Module() { PersistentEntities entities = persistentEntities(); @@ -622,7 +624,7 @@ public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebCon return OrderAwarePluginRegistry.create(converters); } - private List defaultMethodArgumentResolvers() { + protected List defaultMethodArgumentResolvers() { SpelAwareProxyProjectionFactory projectionFactory = new SpelAwareProxyProjectionFactory(); projectionFactory.setBeanFactory(applicationContext); @@ -642,15 +644,15 @@ public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebCon @Autowired GeoModule geoModule; - private ObjectMapper basicObjectMapper() { + protected ObjectMapper basicObjectMapper() { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true); objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - objectMapper.registerModule(geoModule); + Jackson2DatatypeHelper.configureObjectMapper(objectMapper); // Configure custom Modules configureJacksonObjectMapper(objectMapper); @@ -658,16 +660,12 @@ public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebCon return objectMapper; } - private RelProvider getDefaultedRelProvider() { - return this.relProvider != null ? relProvider : new EvoInflectorRelProvider(); - } - @SuppressWarnings("unchecked") - private Set> getProjections() { + private Set> getProjections(Repositories repositories) { Set packagesToScan = new HashSet(); - for (Class domainType : repositories()) { + for (Class domainType : repositories) { packagesToScan.add(domainType.getPackage().getName()); }