Skip to content

Custom Jackson2ObjectMapperBuilder is not used when extending WebMvcConfigurationSupport #2116

@sbuettner

Description

@sbuettner

Just curious if i am missing something in this article or is providing a WebMvcConfigurationSupport falling under what is decribed "Without Spring Boot".

I am providing a custom Jackson2ObjectMapperBuilder via an imported configuration class but it is not used by the MappingJackson2HttpMessageConverter. I am not using @EnableMvc because i have to customize the mvc configuration by extending the WebMvcConfigurationSupport which internally creates the MessageConverter without requesting my jacksonBuilder bean :

if (jackson2Present) {
  messageConverters.add(new MappingJackson2HttpMessageConverter());
}

Here is the WebConfig which gets imported:

@Configuration
public class WebConfig extends WebMvcConfigurationSupport {

    @Bean
    MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        ...
        return factory.createMultipartConfig();
    }

}

And here the configuration object which provides a custom jackson builder:

@Configuration
public class JsonConfig {

    @Bean
    public Jackson2ObjectMapperBuilder jacksonBuilder() {
        return new Jackson2ObjectMapperBuilder()
            .indentOutput(true)
            .serializers(...)
       ;
    }

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions