Spring源碼中是使用容器中的ObjectMapper
對象進行序列化和反序列化。
當我們將自定義的ObjectMapper對象放入IOC容器中后,會自動覆蓋SpringBoot自動裝載的ObjectMapper對象。
若是我們在自定義的ObjectMapper
中設置了objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
屬性。
那么可能會影響我們的@RequestBody
反序列化JSON串,
將配置類的 om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); 注釋掉.