簡體   English   中英

Spring GCP 數據存儲接口:設置命名空間?

[英]Spring GCP Datastore interface: setting the namespace?

我想使用 Spring DatastoreOperations 接口(com.google.cloud.spring.data.datastore.core.DatastoreTemplate.save() 方法)將實體保存到 Google Datastore。 但是,我還需要指定數據存儲命名空間,因為我的數據存儲在每個用戶的單獨命名空間中。 這完全可以使用 Spring 抽象嗎? 當我在 application.properties (spring.cloud.gcp.datastore.namespace=...) 中對命名空間進行硬編碼時,它可以工作,但顯然我需要根據請求在運行時設置它。

好的,我想我找到了解決方案:實現一個 DatastoreNamespaceProvider 類型的 bean 似乎正好解決了這個需求。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM