@EnableWebMvc“禁用” Jackson2ObjectMapperBuilderCustomizer如何解决?

时间:2018-11-22 19:21:16

标签: java spring spring-mvc spring-boot jackson

我已经确定注释内省者(source

public Jackson2ObjectMapperBuilderCustomizer addCustomBigDecimalDeserialization() {
    return new Jackson2ObjectMapperBuilderCustomizer() {
        @Override
        public void customize(Jackson2ObjectMapperBuilder jacksonObjectMapperBuilder) {
            jacksonObjectMapperBuilder.annotationIntrospector(
                    new JacksonAnnotationIntrospector() {
                        @Override
                        public JsonPOJOBuilder.Value findPOJOBuilderConfig(AnnotatedClass ac) {
                            if (ac.hasAnnotation(
                                    JsonPOJOBuilder.class)) {//If no annotation present use default as empty prefix
                                return super.findPOJOBuilderConfig(ac);
                            }
                            return new JsonPOJOBuilder.Value("build", "");
                        }
                    }
            );
        }
    };
}

一切正常,直到我将@EnableWebMvc添加到Applciation类中为止。现在,所有具有龙目岛@Value@Builder批注的dto都为null。似乎我的注释内省者在春天被替换为某些地方。但是哪里?春季boot documentation说,定义Jackson2ObjectMapperBuilderCustomizer bean就足够了。

有什么想法如何使用@EnableWebMvc配置/修复设置注释自省者?

0 个答案:

没有答案