gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 06:29:35 36 4
gpt4 key购买 nike

这是 gradle 依赖项。 (已更新)

   compile group: 'net.sf.ehcache', name: 'ehcache', version: '2.10.4'
compile 'org.springframework:spring-context-support:4.3.8.RELEASE'
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.6'

compile group: 'com.google.api-client', name: 'google-api-client', version: '1.20.0'

此代码生成错误。

   HttpTransport transport = new NetHttpTransport();
JacksonFactory jsonFactory =
new JacksonFactory();
GoogleIdTokenVerifier verifier = new GoogleIdTokenVerifier.Builder(
transport, jsonFactory)
.setAudience(Collections.singletonList("1009293319809-dek5gcam0af2c52ute611c8p51cfvker.apps.googleusercontent.com"))
// Or, if multiple clients access the backend:
//.setAudience(Arrays.asList(CLIENT_ID_1, CLIENT_ID_2, CLIENT_ID_3))
.build();

收到错误

Caused by: java.lang.NoClassDefFoundError: com/google/api/client/json/JsonFactory
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethods(Class.java:1975)
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:613)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:524)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:510)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:247)
... 63 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.google.api.client.json.JsonFactory
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1892)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1735)
... 70 common frames omitted

enter image description here

知道我缺少哪个库吗?我假设库可能存在冲突。我该如何解决这个问题?

最佳答案

您的屏幕截图显示了 google-api-client 库的 2 个版本:

enter image description here

此外,您将在 gradle 构建文件中导入库两次:

compile group: 'com.google.api.client', name: 'google-api-client', version: '1.4.1-beta'
...
compile group: 'com.google.api-client', name: 'google-api-client', version: '1.20.0'

您收到 java.lang.NoClassDefFoundError 的事实似乎是由于旧版本的库不包含提到的类并且它覆盖了最新版本的库图书馆。您需要做的就是从 gradle 文件中删除对旧版本库 (1.4.1-beta) 的引用。

关于java.lang.NoClassDefFoundError : com/google/api/client/json/JsonFactory issue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46414570/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com