为什么GAX中缺少PropertiesProvider?

时间:2018-11-07 14:55:27

标签: java google-cloud-storage

当我尝试执行StorageOptions.getDefaultInstance().getService()时。我看到了这个失败:

2018-11-07 20:13:58 [http-nio-8442-exec-2] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet].log(182) - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: com/google/api/gax/core/PropertiesProvider] with root cause
java.lang.ClassNotFoundException: com.google.api.gax.core.PropertiesProvider
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
    at com.google.cloud.ServiceOptions.getVersionProperty(ServiceOptions.java:647)
    at com.google.cloud.ServiceOptions.getLibraryVersion(ServiceOptions.java:565)
    at com.google.cloud.http.HttpTransportOptions.getHttpRequestInitializer(HttpTransportOptions.java:152)
    at com.google.cloud.storage.spi.v1.HttpStorageRpc.<init>(HttpStorageRpc.java:90)
    at com.google.cloud.storage.StorageOptions$DefaultStorageRpcFactory.create(StorageOptions.java:53)
    at com.google.cloud.storage.StorageOptions$DefaultStorageRpcFactory.create(StorageOptions.java:47)
    at com.google.cloud.ServiceOptions.getRpc(ServiceOptions.java:472)
    at com.google.cloud.storage.StorageOptions.getStorageRpcV1(StorageOptions.java:121)
    at com.google.cloud.storage.StorageImpl.<init>(StorageImpl.java:99)
    at com.google.cloud.storage.StorageOptions$DefaultStorageFactory.create(StorageOptions.java:43)
    at com.google.cloud.storage.StorageOptions$DefaultStorageFactory.create(StorageOptions.java:37)
    at com.google.cloud.ServiceOptions.getService(ServiceOptions.java:459)

我在pom.xml中包含了gax-grpc依赖项:

    <dependency>
        <groupId>com.google.api</groupId>
        <artifactId>gax-grpc</artifactId>
        <version>1.34.0</version>
    </dependency>

在线搜索此错误表示,如果dependency:tree中有多个gax版本,则可能是这样,我已经验证了gax版本只有一个。

我不明白为什么这会失败,有人知道这里出了什么问题吗?

1 个答案:

答案 0 :(得分:1)

当我们将google-cloud-storage版本从1.10.0更新到1.51.0时,此问题已解决