#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' 已弃用.我有哪些选择?
基础教程推荐
- Java Swing计时器未清除 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 多个组件的复杂布局 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 大摇大摆的枚举 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
