我已经确定注释内省者(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
配置/修复设置注释自省者?