my goal is to configure the objectMapper in the way that it only serialises element which are annotated with @JsonProperty.
In order to do
Above Spring 4, there is no need to configure MappingJacksonHttpMessageConverter if you only intend to configure ObjectMapper.
(configure MappingJacksonHttpMessageConverter will cause you to lose other MessageConverter)
You just need to do:
public class MyObjectMapper extends ObjectMapper {
private static final long serialVersionUID = 4219938065516862637L;
public MyObjectMapper() {
super();
enable(SerializationFeature.INDENT_OUTPUT);
}
}
And in your Spring configuration, create this bean:
@Bean
public MyObjectMapper myObjectMapper() {
return new MyObjectMapper();
}