选择要连接的 Firestore 数据库

Choose which Firestore database to connect

提问人:Roland 提问时间:11/17/2023 最后编辑:Frank van PuffelenRoland 更新时间:11/17/2023 访问量:29

问:

我的谷歌云“默认”和“mydb”中有两个 Firestore 数据库。当我将Spring Boot应用程序设置为连接到数据库时,它始终连接到“默认”应用程序。如何连接到我的Spring Boot应用程序中的“mydb”数据库?

java spring-boot google-cloud-firestore

评论


答:

1赞 Frank van Puffelen 11/17/2023 #1

您将使用类似于 Firestore 文档中有关初始化客户端的代码片段,但随后在构建器中,请确保调用 setDatabaseId,传入要访问的实例的数据库 ID。

评论

0赞 Roland 11/17/2023
成功了。谢谢。有没有办法同时使用“spring-cloud-gcp-starter-data-firestore”中的这个(FirestoreOptions)和FirestoreReactiveRepository?我的意思是自定义 FirestoreReactiveRepository 以使用我与 FirestoreOptions 连接的 firestore。
1赞 Frank van Puffelen 11/17/2023
对不起,我从未使用过,也没有快速看到如何使用它的示例,所以我无法对此发表评论。FirestoreReactiveRepository
0赞 Roland 11/17/2023
没问题,弗兰克。非常感谢您的帮助。