Spring Cloud GCP Cloud Datastore Starter Example
This code sample demonstrates how to read and write POJOs from Google Cloud Datastore using the Spring Data Cloud Datastore module Spring Cloud GCP Cloud Datastore Starter.
Running the example
Create a new Cloud Datastore database in your GCP project if this has not already been done to allow Cloud Datastore to create and store entities.
If you are authenticated in the Cloud SDK, your credentials will be automatically found by the Spring Boot Starter for Google Cloud Datastore.
Alternatively, create a service account from the Google Cloud Console and download its private key.
Then, uncomment the
spring.cloud.gcp.datastore.credentials.locationproperty in the application.properties file and fill its value with the path to your service account private key on your local file system, prepended with
DatastoreRepositoryExampleSpring Boot console app. This causes the app to generate sample
Singerobjects filled with some demo data and persists them to Cloud Datastore. These POJOs are then retrieved and their contents are printed in the output.