问题
I am desperately trying to compile
Quickstart: Run a Drive App in Java
but no matter what, I always hit on:
java.lang.NoSuchMethodError: com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient
The same thing happens both for at the servlet and the SE version.
Any ideas?
回答1:
The code compiled and ran fine here.
Steps:
Create/select a project at Google Developer Console , enable the Drive API, create a new Client ID so that you have a valid
CLIENT_ID
,CLIENT_SECRET
,REDIRECT_URI
.Download
google-api-services-drive-v2-rev123-java-1.18.0-rc.zip
, extract it and put the following jars in your classpath.

Create a text file
document.txt
and put it in the same package(assuming you are using eclipse as IDE) as your source code.Provide the generated CLIENT_ID,CLIENT_SECRET,REDIRECT_URI(Step 1) in your source code.
Compile and run the code.
Output:

Copy the code provided in the browser, paste it in console.
The document will be uploaded to your Google Drive.
回答2:
Well, I had to use the suitable Drive API from Drive API Client Library for Java
来源:https://stackoverflow.com/questions/23613317/google-drive-java-api