Last time implemented the access logic to Datastore in test first. This time, I will write briefly about how to start the GAE application locally and check the operation.
-GAE / Java8 trial (No. 0: "About App Engine") -GAE / Java8 trial (Part 1: "Create and deploy a web application with Java8") -GAE / Java8 trial (Part 2: "Java application explanation") -GAE / Java8 trial (Part 3: "Java application test code explanation") -GAE / Java8 trial (4: "Access logic to Datastore")
$ cat /etc/os-release
NAME="Ubuntu"
VERSION="17.10 (Artful Aardvark)"
$ java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
Everyone loves IntelliJ IDEA
--Use Java Local Development Server
A little modification of the source I wrote last time.
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String id = req.getParameter("id");
String name = req.getParameter("name");
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
Entity e = new Entity(KeyFactory.createKey("book", Integer.parseInt(id)));
e.setProperty("bookName", name);
ds.put(e);
}
First, start the local development server. This is as in Previously written article.
$ mvn appengine:run
Confirm by POST with Postman.
Although it is the logic to register the request parameter in the Datastore, it is unknown whether it was processed normally because it does not return any response. At times like this (not limited to this time ...), use the console for local development.
http://localhost:8080/_ah/admin
Access here.
Then, such a screen is displayed. This is the "console for local development".
Then, when you press "List Entries", you can see that the contents loaded in the request parameters by Postman are registered in the Datastore.
You can see the status of the Task queue as well as the Datastore. You can also control access to resources such as Datastore, Memcache, and Task queues. This is convenient.
Recommended Posts