I'm trying to use the Google Cloud Storage SDK for Java into my Spring application.
Using Maven I've added it to my dependencies:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
<version>1.31.0</version>
</dependency>
Then I try to initialize the Storage client with:
client = StorageOptions.newBuilder()
.setCredentials(ServiceAccountCredentials.fromStream(new ClassPathResource("/my/path/to.json").getInputStream()))
.build()
.getService();
but an error occurs
java.lang.NoSuchMethodError: com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient$Builder.setBatchPath
I've noticed that in my google-api-client-1.23.0.jar libray loaded as dependency no setBatchPath was present.
I've tried to find the issue browsing on web but without fortune. I cannot understand which library (and version) I need to install in order to make it works.
Thanks in advance.
Eventually I solved, there was a library duplication between my Web Application and Its Business Layer Jar component (I have a multi-module Project).
What I cannot understand is why there was a call to a non-existing method ( AbstractGoogleJsonClient$Builder.setBatchPath
) that was solved in this way.
In google-api-client-1.20.0.jar
that method does not exists nor in google-api-client-1.23.0.jar
尝试阅读this ,然后您可能可以解决该错误。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.