I am using Java 17, spring-boot 2.6.3 and spring-webflux and I have set up a repository in order to demonstrate that even though my customObjectMapper is actually show in actuator/beans and actuator/conditions endpoints, it is not being used when rendering the response.

Here's the code that creates my customObjectMapper:

import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
import org.springframework.context.annotation.Primary;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.web.reactive.config.EnableWebFlux;

import com.enterprise.project.serializer.ModelSerializer;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;

@SpringBootApplication
@EnableWebFlux
public class Application {

    public static void main(final String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Bean
    static BeanFactoryPostProcessor beanFactoryPostProcessor(final ApplicationContext beanRegistry) {
        return (final var beanFactory) -> {
            final var beanDefinitionScanner = new ClassPathBeanDefinitionScanner(
                    (BeanDefinitionRegistry) ((AnnotationConfigReactiveWebServerApplicationContext) beanRegistry)
                            .getBeanFactory());
            beanDefinitionScanner.addIncludeFilter(
                    (final var mr, final var mrf) -> !mr.getClassMetadata().getClassName().contains("model"));

            beanDefinitionScanner.scan("com.enterprise.project");
        };
    }

    @Bean
    @Primary
    public ObjectMapper customObjectMapper(final Jackson2ObjectMapperBuilder builder) {
        return builder.serializationInclusion(JsonInclude.Include.NON_NULL).serializers(new ModelSerializer()).build();
    }
}

I also have placed a question in Stackoverflow.

Comment From: wilkinsona

People are already trying to help you on Stack Overflow. To avoid wasting their time, and the time of anyone else who tries to help over there, I'm going to close this issue for now. We can re-open it if it turns out that there's a bug that we need to fix.