是否有一种方法可以创建用于不同目的的ObjectMapper的两个实例。
Modified ObjectMapper
@Component
class MyObjectMapper extends ObjectMapper{
public MyObjectMapper(){
super();
}
public MyObjectMapper(MyObjectMapper om) {
super(om);
}
@Override
public MyObjectMapper copy() {
return new MyObjectMapper(this);
}
}
现在按如下使用它
@Autowired ObjectMapper objectMapper; //performs standard serialization
@Autowire MyObjectMapper myMapper; //i can add custom filters in thiis mapper.
我尝试过类似的设置,但自定义映射器实际上会影响所有rest controllers
抛出JSON parse error: Unrecognized field
的原始映射器>
是否有一种方法可以创建用于不同目的的ObjectMapper的两个实例。修改的ObjectMapper @Component类MyObjectMapper扩展了ObjectMapper {public MyObjectMapper(){...