将 firestore 用于 spring-boot rest api [英] Using firestore for spring-boot rest api

查看:51
本文介绍了将 firestore 用于 spring-boot rest api的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 spring-boot 制作我自己的 rest-api.我应该开始使用 firestore 作为我的主要数据库吗?我在互联网上进行了搜索,但没有发现将 sping-boot 与 firestore 数据库一起使用的必要条件.我不知道在 Spring Boot 中使用普通数据库或 Firestore 的问题.

I want to make my own rest-api using spring-boot. Should I jump into using firestore as my primary database ? I have searched over internet but found nothing essential for using sping-boot with firestore database. I don't know the issues of using normal database or firestore with spring boot.

推荐答案

你可以使用 firestore 作为你的数据库,实现是相当有前途的在此处输入链接描述

You can use firestore as your database, implementation is pretty forward enter link description here

使用以下依赖

依赖项{编译组:'org.springframework.cloud',名称:'spring-cloud-gcp-starter-firestore'}

dependencies { compile group: 'org.springframework.cloud', name: 'spring-cloud-gcp-starter-firestore' }

自动装配您的 Firestore 实例

Autowire your firestore instance

@AutowiredFirestore Firestore;

@Autowired Firestore firestore;

要写入 firestore,请使用以下代码

For writing to firestore use the following code

WriteResult writeResult = this.firestore.document("users/joe").set(data).get();

WriteResult writeResult = this.firestore.document("users/joe").set(data).get();

您必须在应用程序属性中指定您的项目 IDspring.cloud.gcp.firestore.project-id = abcdefg

you have to specify your project id in application properties spring.cloud.gcp.firestore.project-id = abcdefg

这篇关于将 firestore 用于 spring-boot rest api的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆