#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' 已弃用.我有哪些选择?


- 转换 ldap 日期 2022-01-01
- java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01
- 获取数字的最后一位 2022-01-01
- 如何指定 CORS 的响应标头? 2022-01-01
- 未找到/usr/local/lib 中的库 2022-01-01
- GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01
- 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
- Eclipse 的最佳 XML 编辑器 2022-01-01
- 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01
- 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01