springboot 使用自己的fastJson框架
来源:互联网 发布:淘宝魔镜软件管用吗 编辑:程序博客网 时间:2024/05/16 18:03
1.pom.xml
<dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.31</version></dependency>
2.1方法一:继承WebMvcConfigurerAdapter,重载configureMessageConverters
@Overridepublic void configureMessageConverters(java.util.List<org.springframework.http.converter.HttpMessageConverter<?>> converters) { //1.需要定义一个convert转换消息的对象 FastJsonHttpMessageConverter converter=new FastJsonHttpMessageConverter(); //2.添加fastJson的配置信息,比如:是否要格式化返回的json数据; FastJsonConfig config=new FastJsonConfig(); config.setSerializerFeatures(SerializerFeature.PrettyFormat); //3.在convert添加配置信息 converter.setFastJsonConfig(config); //4.在convert添加到converts中 converters.add(converter);};
2.2使用bean注解的方式
@Beanpublic HttpMessageConverters getConverters(){ FastJsonHttpMessageConverter converter=new FastJsonHttpMessageConverter(); FastJsonHttpMessageConverter fastconverter=new FastJsonHttpMessageConverter(); FastJsonConfig config=new FastJsonConfig(); config.setSerializerFeatures(SerializerFeature.PrettyFormat); converter.setFastJsonConfig(config); HttpMessageConverter<?> converter1=fastconverter; return new HttpMessageConverters(converter1);}
阅读全文
0 0
- springboot 使用自己的fastJson框架
- SpringBoot 之 第三方Json解析框架FastJson的使用
- springboot使用第三方的json解析框架fastjson
- springboot使用fastjson
- SpringBoot中使用fastjson
- springboot使用fastjson
- SpringBoot 使用fastjson初识
- springboot使用webmagic框架来抓取自己的博客信息
- fastjson在springboot中的使用
- springboot系列文章(四)-springboot使用fastjson
- Springboot使用FastJson后,接口返回中文乱码的问题解决。
- 解决Springboot使用FastJson 返回中文乱码的问题
- fastjson框架使用
- springboot 使用RestTemplate 使用FastJson处理结果
- FastJson-fastjson的简单使用
- SpringBoot使用FastJson解析Json数据
- Springboot使用FastJson中文乱码解决方法。
- Android常用Json解析框架GSON和FastJson的使用
- mysql数据库最大连接数设置
- Unity 3D之调用摄像头并存储
- Sailing(BFS 金马五校赛-东华大学 )
- leetcode[Binary Watch]
- Android在子线程更新UI界面
- springboot 使用自己的fastJson框架
- 动态规划7:最长上升子序列LIS
- 乱七八糟
- Android
- python连接mysql和sqlsever驱动
- 关于不同像素设备替换不同图片的问题
- 最短路问题,多源、SPFA变形
- Linux下守护进程
- netty 发送 超过 1024 数据