问题
I have implemented the Java QuickStart for the Classroom API and am getting an error message "java.io.FileNotFoundException: Resource not found: /credentials.json" at run-time. I copied my credentials.json file to the Project res directory, but continue to get this error. Any suggestions?
回答1:
I tried it in a different way than I found on other websites, and it worked for me.
replace below code:
InputStream in = GoogleSheetAPIHandler.class.getClass().getResourceAsStream(CREDENTIALS_FILE_PATH);
With this code:
InputStream in = new FileInputStream(CREDENTIALS_FILE_PATH);
回答2:
You need to import credential.json file into the src/main/resources folder in eclipse. You may be included in the project folder. But you need to import it into eclipse.
- locate your credentials.json file in the folder.
- click and drag it
- drop it in src/main/resource and click ok.
- After importing into eclipse it should show like the below image.
来源:https://stackoverflow.com/questions/59292883/java-io-filenotfoundexception-resource-not-found-credentials-json-on-java-qui