#39;com.google.api.client.json.jackson2.JacksonFactory#39; is deprecated. What are my options?(com.google.api.client.json.jackson2.JacksonFactory 已弃用.我有哪些选择?)
问题描述
在遵循 Gmail API java 快速入门指南时,我遇到了这个代码片段:
While following the Gmail API java quickstart guide I came across this code snippet:
private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
在编辑器中使用它给了我一个警告,它已被弃用.我有哪些选择?
Using it in the editor gave me a warning that it is deprecated. What are my options?
推荐答案
查找JacksonFactory 类的 API 文档.它告诉你该怎么做:
Look up the API documentation of class JacksonFactory.
It tells you what to do:
已弃用.
改用 com.google.api.client.json.GsonFactory
Deprecated.
use com.google.api.client.json.GsonFactory instead
查看 类GsonFactory的API文档你看,它的 API 方法与 JacksonFactory 的方法兼容,因为两者都从同一个超类 JsonFactory 扩展而来.(当然,只有它们的内部实现不同.)
Looking into the API documentation of class GsonFactory
you see, its API methods are compatible to those of JacksonFactory,
since both extend from the same superclass JsonFactory.
(Only their internal implementations are different, of course.)
因此,更改代码很简单.只是为了换行
Therefore it is simple to change your code. Just to replace the line
private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
通过
private static final JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance();
这篇关于'com.google.api.client.json.jackson2.JacksonFactory' 已弃用.我有哪些选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:'com.google.api.client.json.jackson2.JacksonFactory' 已弃用.我有哪些选择?
基础教程推荐
- 将 double 转换为 Int,向下舍入 2022-01-01
- Maven:无效的目标版本:10 2022-01-01
- JPA惰性列表上的流 2022-01-01
- 控制台应用程序中的 Java 键盘输入解析 2022-01-01
- 在java中使用xpath和selenium解析HTML表格数据 2022-01-01
- 如何在相机中应用自定义滤镜 [Surfaceview 预览]. 2022-01-01
- doFilter()是在servlet的工作完成之前还是之后执行的? 2022-01-01
- 将 Windows 证书导入 Java 2022-01-01
- Java ECDSAwithSHA256 签名长度不一致 2022-01-01
- 在springboot中如何给mybatis加拦截器 2023-04-29
