Objectify is a third-party library for interfacing with Datastore from Java applications. Cloud Tools for Eclipse allows users to add Objectify, as well as other Google Cloud libraries, to their projects.
This document describes how to configure Cloud Tools for Eclipse to use Objectify when running your application locally.
To configure Cloud Tools for Eclipse to use Objectify:
In Eclipse, select Run > Run Configurations.
In the Run Configurations dialog, select an existing App Engine Local Server launch configuration, or click the New launch configuration button to create one.
Select the Cloud Platform tab of your run configuration.
Select an account.
Select a project to assign a project ID to be used in the local run. It doesn't matter which project you select because you won't actually connect to it.
- As an alternative, if you aren't logged in or don't have a Cloud Project, you can instead set the GOOGLE_CLOUD_PROJECT environment variable to a legal string, such as MyProjectId, in the Environment tab of the run configuration.
Switching Datastore emulator
Objectify 6 may have an issue working with the bundled datastore emulator in
dev_appserver, but it does work with the beta
To use the
Launch a terminal and run:
gcloud beta emulators datastore start
As the emulator starts up, a message displays, similar to this one:
[datastore] API endpoint: http://localhost:8081 [datastore] If you are using a library that supports the DATASTORE_EMULATOR_HOST environment variable, run: [datastore] [datastore] export DATASTORE_EMULATOR_HOST=localhost:8081 [datastore] [datastore] Dev App Server is now running.
In Eclipse, add the DATASTORE_EMULATOR_HOST environment variable to your run configuration in the Environment tab.
- In this example, set the name to DATASTORE_EMULATOR_HOST and the value to localhost:8081.
If you use the
gcloud-based datastore emulator, you won't find any data on the Datastore admin page for the local