简体   繁体   English

java.lang.ClassNotFoundException:com.google.api.client.json.JsonFactory

[英]java.lang.ClassNotFoundException: com.google.api.client.json.JsonFactory

I want to create a web application running on Tomcat 7.0 with JRE JavaSE-1.6 on osx 10.8.我想创建一个在 Tomcat 7.0 上运行的 web 应用程序,在 osx 10.8 上使用 JRE JavaSE-1.6。 I am using a tutorial from the developers site and the error occurs when I try to call我正在使用来自开发者网站的教程,当我尝试调用时出现错误

clientSecrets = GoogleClientSecrets.load(new JacksonFactory(), reader);

I added the Jar google-http-client-jackson-1.16.0-rc.jar to my build path and still get following error:我将 Jar google-http-client-jackson-1.16.0-rc.jar 添加到我的构建路径中,但仍然出现以下错误:

java.lang.NoClassDefFoundError: com/google/api/client/json/JsonFactory
java.lang.ClassNotFoundException: com.google.api.client.json.JsonFactory

My classpath specifically points to this Jar too.我的类路径也特别指向这个 Jar。

I just fixed this by changing the following lines:我只是通过更改以下行来解决此问题:

Original: import com.google.api.client.json.jackson.JacksonFactory;原文: import com.google.api.client.json.jackson.JacksonFactory;

Modified: import com.google.api.client.json.jackson2.JacksonFactory;修改: import com.google.api.client.json.jackson2.JacksonFactory;

I had a similar problem and solved it by manually adding the required JAR's to my WEB-INF\lib folder outside Eclipse.我遇到了类似的问题,并通过手动将所需的 JAR 添加到 Eclipse 之外的我的 WEB-INF\lib 文件夹中解决了这个问题。

From this page here , it says you need 3 libraries: 1) The Generated Java client library for BigQuery 2) The Google HTTP Client Library for Java 3) The Google OAuth Client Library for Java页面上,它说您需要 3 个库:1) BigQuery 生成的 Java 客户端库 2) Java 的 Google HTTP 客户端库 3) Java 的 Google OAuth 客户端库

Do you have them all?你都有吗? It sounds like you have #2, but it sounds like you're missing the google HTTP client .听起来您有 #2,但听起来您缺少 google HTTP client

  1. In POM add below dependency-在 POM 中添加以下依赖项-

     <dependency> <groupId>com.google.api-client</groupId> <artifactId>google-api-client-gson</artifactId> <version>2.1.1</version> </dependency> <dependency> <groupId>com.google.oauth-client</groupId> <artifactId>google-oauth-client-jetty</artifactId> <version>1.34.1</version> </dependency>

Note: In above dependency version can be changed注意:在上面的依赖版本中可以更改

2.Import statement 2.导入声明

    import com.google.api.client.json.JsonFactory;
    import com.google.api.client.json.gson.GsonFactory;
  1. Usage用法

     private static final JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance(); GoogleClientSecrets clientSecrets =GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 类型 com.google.api.client.json.JsonFactory 无法解析 - The type com.google.api.client.json.JsonFactory cannot be resolved AWS Lambda Java 到 S3 - com.amazonaws.services.s3.AmazonS3ClientBuilder 上的 java.lang.ClassNotFoundException - AWS Lambda Java to S3 - java.lang.ClassNotFoundException on com.amazonaws.services.s3.AmazonS3ClientBuilder AWS Lambda java.lang.ClassNotFoundException: com.opencsv.exceptions.CsvException - AWS Lambda java.lang.ClassNotFoundException: com.opencsv.exceptions.CsvException 使用 Amazon S3 配置 Pyspark 给出 java.lang.ClassNotFoundException: com.amazonaws.auth.AWSCredentialsProvider - Configuring Pyspark with Amazon S3 giving java.lang.ClassNotFoundException: com.amazonaws.auth.AWSCredentialsProvider java.lang.NoSuchMethodError: 'boolean com.google.api.client.http.HttpTransport.isMtls() - java.lang.NoSuchMethodError: 'boolean com.google.api.client.http.HttpTransport.isMtls() GCS Hadoop 连接器错误:ClassNotFoundException:com.google.api.client.http.HttpRequestInitializer ls:方案 gs 没有文件系统 - GCS Hadoop connector error: ClassNotFoundException: com.google.api.client.http.HttpRequestInitializer ls: No FileSystem for scheme gs Spring Boot 3.0.0,SQS:java.lang.ClassNotFoundException:org.springframework.messaging.handler.annotation.support.PayloadArgumentResolver - Spring Boot 3.0.0, SQS: java.lang.ClassNotFoundException: org.springframework.messaging.handler.annotation.support.PayloadArgumentResolver Google App Engine:java.lang.ClassCastException:com.google.appengine.api.datastore.Key 无法转换为 java.lang.Integer - Google App Engine: java.lang.ClassCastException: com.google.appengine.api.datastore.Key cannot be cast to java.lang.Integer Firebase 奇怪的错误 java.lang.ClassNotFoundException:不是在开发期间,而是在 apk 发布之后 - Firebase weird error java.lang.ClassNotFoundException: not during development, but after apk released Android API 24 < 崩溃 java.lang.NoClassDefFoundError: com.google.common.base.CharMatcher - Android API 24 < Crashes with java.lang.NoClassDefFoundError: com.google.common.base.CharMatcher
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM