当前位置:   article > 正文

springboot 使用fastjson自定义序列化和反序列化_springboot fastjson 泛型 无法返序列化

springboot fastjson 泛型 无法返序列化

注意:本文以序列化枚举转换为例

一、引入fastjson依赖

  1. <dependency>
  2. <groupId>com.alibaba</groupId>
  3. <artifactId>fastjson</artifactId>
  4. <version>1.2.58</version>
  5. </dependency>

二、配置fastjson替代jackson

  1. package com.cdn.one.config;
  2. import com.alibaba.fastjson.serializer.SerializerFeature;
  3. import com.alibaba.fastjson.support.config.FastJsonConfig;
  4. import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
  5. import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
  6. import org.springframework.context.annotation.Bean;
  7. import org.springframework.context.annotation.Configuration;
  8. import org.springframework.http.MediaType;
  9. import org.springframework.http.converter.HttpMessageConverter;
  10. import java.nio.charset.StandardCharsets;
  11. import java.util.ArrayList;
  12. import java.util.List;
  13. /**
本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/897323
推荐阅读
相关标签
  

闽ICP备14008679号