Spring-boot中使用fastjson作为json框架
来源:互联网 发布:上海灵娱网络 编辑:程序博客网 时间:2024/06/02 02:40
第一步:
在pom文件中引入fastjson依赖
<dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.15</version></dependency>
配置fastjson(两种方法)
第一种方法:
(1)启动类继承extends WebMvcConfigurerAdapter
(2)覆盖方法configureMessageConverters
@SpringBootApplicationpublic class ApiCoreApp extends WebMvcConfigurerAdapter { @Override public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { super.configureMessageConverters(converters); FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter(); FastJsonConfig fastJsonConfig = new FastJsonConfig(); fastJsonConfig.setSerializerFeatures( SerializerFeature.PrettyFormat ); fastConverter.setFastJsonConfig(fastJsonConfig); converters.add(fastConverter); }}
第二种在启动类中注入Bean:HttpMessageConverters
@Bean public HttpMessageConverters fastJsonHttpMessageConverters() { FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter(); FastJsonConfig fastJsonConfig = new FastJsonConfig(); fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat); fastConverter.setFastJsonConfig(fastJsonConfig); HttpMessageConverter<?> converter = fastConverter; return new HttpMessageConverters(converter); }
阅读全文
0 0
- Spring-boot中使用fastjson作为json框架
- Spring Boot 使用json框架fastjson
- Spring Boot使用FastJson解析JSON数据
- spring boot:使用fastJson解析json数据
- spring boot 使用fastjson
- spring boot使用fastjson
- 【传智播客郑州校区分享】Spring Boot中使用FastJson解析Json数据
- Spring中使用FastJson返回json数据
- 4. Spring Boot 完美使用FastJson解析Json数据
- Spring Boot 学习4--完美使用FastJson解析Json数据
- 【Spring Boot】完美使用FastJson解析JSON数据
- Spring Boot 使用第三方json解析 : fastjson
- Spring Boot完美使用FastJson解析JSON数据(十三)
- (4)Spring Boot完美使用FastJson解析JSON数据【从零开始学Spring Boot】
- 78. Spring Boot完美使用FastJson解析JSON数据【从零开始学Spring Boot】
- 78. Spring Boot完美使用FastJson解析JSON数据【从零开始学Spring Boot】
- spring-boot实现FastJson解析json数据
- spring boot 配置fastjson解析json
- python八枚硬币问题
- 数列特征
- GitHub 版本控制 项目托管 06 创建GitHub本地仓库2-加入代码工程
- 算法详解之MD5...
- 第四周项目2-单链表算法库
- Spring-boot中使用fastjson作为json框架
- Gemini Blueprint参考文档 第8章 打包和部署基于Spring的OSGi应用
- Fegin 请求日志查看配置
- 链表的高级特性
- 每个程序员都该知道的5个定律
- PHP smarty
- RxJava详解
- MySQL数据库安装与配置详解
- SSM(Spring+SpringMVC+Mybatis)框架整合配置方法