亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

通過嘗試從 Googl-Cloud-Storage 讀取值來獲得無效授權

通過嘗試從 Googl-Cloud-Storage 讀取值來獲得無效授權

浮云間 2023-06-14 16:33:21
我試圖從我的 Spring 應用程序中讀取 Google-Cloud 存儲中的值。我使用 Spring Cloud GCP 擴展來處理 Google Cloud Storage。我的 gcp 依賴項的 Pom.xml:<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-gcp-starter-storage</artifactId>  <version>1.1.2.RELEASE</version></dependency>當我嘗試從我的休息端點讀取文件時,我得到異常(在我的回答結束時)不知何故我的令牌無法刷新?我在哪里可以設置我的 clientId 或者還有其他事情發生?我使用了 pivotal 和 google 提供的示例應用程序中的代碼。@RestControllerpublic class GCloudStorageController {    @Value("gs://test_files_test/test.txt")    private Resource gcsFile;    @RequestMapping(value = "/cloud", method = RequestMethod.GET)    public String readGcsFile() throws IOException {        return StreamUtils.copyToString(                this.gcsFile.getInputStream(),                Charset.defaultCharset()) + "\n";    }    @RequestMapping(value = "/cloud", method = RequestMethod.POST)    String writeGcs(@RequestBody String data) throws IOException {        try (OutputStream os = ((WritableResource) this.gcsFile).getOutputStream()) {            os.write(data.getBytes());        }        return "file was updated\n";    }}
查看完整描述

2 回答

?
弒天下

TA貢獻1818條經驗 獲得超8個贊

這看起來像是關于身份驗證的問題。您是否遵循了通用的“Spring Cloud GCP Core”[1] 配置?

檢查您的 application.properties [2](或其他配置)并確保它至少包含以下屬性:

spring.cloud.gcp.datastore.project-id=XXX
spring.cloud.gcp.datastore.credentials.location=YYY

或選擇 [1] 中顯示的其他方法。

[1] https://cloud.spring.io/spring-cloud-static/spring-cloud-gcp/1.1.2.RELEASE/single/spring-cloud-gcp.html#spring-cloud-gcp-core

[2] https://github.com/spring-cloud/spring-cloud-gcp/blob/master/spring-cloud-gcp-samples/spring-cloud-gcp-data-datastore-sample/src/main/resources/application.properties


查看完整回答
反對 回復 2023-06-14
?
互換的青春

TA貢獻1797條經驗 獲得超6個贊

教程中從未提及實施“Spring Cloud GCP Core”的資源,或者我忽略了它。

我的控制臺上的 Google Cloud SDK 以某種方式連接了另一個帳戶。所以我用

gcloud auth application-default login

并登錄正確的帳戶?,F在可以了。謝謝。


查看完整回答
反對 回復 2023-06-14
  • 2 回答
  • 0 關注
  • 178 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號