Skip to content

MappingJackson2HttpMessageConverter bean not being automatically added to MvcConfig's converters list #47989

@robdipietro

Description

@robdipietro

In order to be ready for Boot 4.0 we're attempting an upgrade from 3.5.7 to 4.0.0-RC2. We're not ready/able to wholesale migrate to Jackson 3.0 and so we're leveraging the spring-boot-jackson2 dependency for the upgrade.

In our case we don't use Spring's Jackson two dependencies otherwise, but rather direct dependencies on Jackson's 2.20.1 BOM.

In one of our configuration classes we have a method like:

    @Bean
    public MappingJackson2HttpMessageConverter jsonConverter() {

In which we stand up a Mapper Builder/Mapper that we pass into our own subclass of MappingJackson2HttpMessageConverter and return. We do this to support our own specific JSON transport format.

In Spring Boot 3.5.7 that seems to be the only thing we needed to do for the converter to appear in the converter chain. In Spring Boot 4.0.0-RC1/2 I'm finding that our custom converter is not automatically making it into the chain and I now have to programmatically do so in a WebMvcConfigurer class like so:

    @Autowired private MappingJackson2HttpMessageConverter jsonConverter;

    @Override
    public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {

        int index = -1;
        for (int i = 0; i < converters.size(); i++) {
            HttpMessageConverter<?> converter = converters.get(i);
            if (converter instanceof JacksonJsonHttpMessageConverter) {
                index = i;
                break;
            }
        }

        if (index > 0) {
            //Add before the Jackson 3 converter
            converters.add(index - 1, jsonConverter);
        } else if (index == 0) {
            //Unlikely, but...
            converters.addFirst(jsonConverter);
        } else {
            log.error("Could not find expected converter [{}] in converters chain.", JacksonJsonHttpMessageConverter.class.getName());
            converters.addLast(jsonConverter);
        }
    }

Maybe this is the expected path forward, but haven't seen anything in the documentation that I could find that explicitly calls this out. It could also be that how we've been doing this isn't quite the "Spring way" as we've migrated this application into Spring Boot.

Ultimately though I could see this being a stumbling point for other people that need to upgrade Spring Boot to stay in a supported mode, but have significant Jackson 2.0 investment that needs to be migrated. It seems reasonable to expect that MappingJackson2HttpMessageConverter bean classes would still be automatically added to converters if the app is configured to stay with Jackson 2.0.

Some of the docs I looked at:
https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-4.0-Migration-Guide
https://spring.io/blog/2025/10/07/introducing-jackson-3-support-in-spring

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions