coding++:error Could not read JSON: Unexpected token (START_OBJECT), expected START_ARRAY: need JSON Array to contain As.WRAPPER_ARRAY type information for class java.lang.Object

Spring源码中是使用容器中的ObjectMapper对象进行序列化和反序列化。

当我们将自定义的ObjectMapper对象放入IOC容器中后,会自动覆盖SpringBoot自动装载的ObjectMapper对象。

若是我们在自定义的ObjectMapper中设置了objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);属性。

那么可能会影响我们的@RequestBody反序列化JSON串,

将配置类的 om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); 注释掉.

原文地址:https://www.cnblogs.com/codingmode/p/12606801.html