Apply HATEOAS module to primary ObjectMapper

Update HypermediaAutoConfiguration to apply the Jackson2HalModule to
the primary ObjectMapper. This restores the behavior of Spring Boot
1.1 where HATEOAS types could be serialized for both `application/json`
and `application/json+hal` content types.

A `spring.hateoas.apply-to-primary-object-mapper` property has also been
provided to opt-out if necessary.

Fixes gh-2147
This commit is contained in:
Phillip Webb
2014-12-22 15:12:51 -08:00
parent ea84479e9a
commit fd97c7553c
4 changed files with 132 additions and 27 deletions

View File

@@ -75,19 +75,17 @@ public class HypermediaAutoConfigurationTests {
@Test
public void doesBackOffIfEnableHypermediaSupportIsDeclaredManually() {
this.context = new AnnotationConfigWebApplicationContext();
this.context.register(SampleConfig.class, HypermediaAutoConfiguration.class);
this.context.refresh();
this.context.getBean(LinkDiscoverers.class);
}
@Test
public void jacksonConfigurationIsAppliedToTheHalObjectMapper() {
this.context = new AnnotationConfigWebApplicationContext();
this.context.register(HypermediaAutoConfiguration.class,
JacksonAutoConfiguration.class);
this.context.register(JacksonAutoConfiguration.class,
HypermediaAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context,
"spring.jackson.serialization.INDENT_OUTPUT:true");
this.context.refresh();