Building Scalable Java Microservices with Spring Boot and Spring Cloud学习笔记
- Week 1
- GCP services overview
- Spring Framework Intro
- Week 2
- Lab 1: Bootstrapping the application frontend and backend
- Spring Boot注解
Week 1
GCP services overview
- Cloud Function: provide a completely serverless execution environment or functions as a service
- App engine: that provides a fully managed platform as a service framework.
- Kubernetes engine: that provides a managed containers as a service environment for containerized applications.
- Compute Engine: which is Google’s infrastructure as a service solution that provides maximum flexibility for users and organizations who choose to manage their solutions themselves.
Migrate from using a Cloud SQL instance to a Cloud Spanner instance to meet the needs for high levels of transactional performance.
Spring Framework Intro
Spring framework: an open source application framework and inversion of control container developed by Pivotal for the Java platform.
Spring boot: a spring framework solution designed to simplify the bootstrapping and development of stand-alone production spring based applications.
Week 2
Lab 1: Bootstrapping the application frontend and backend
Cloudshell
is an interactive Linux command line shell environment for managing resources hosted on GCP. When you start Cloudshell, it provisions a small compute engine virtual machine, running a Debian-based Linux operating system. Cloud Shell provides command line access to the virtual machine instance in a terminal window that opens in the GCP console.
Lab Link
Objectives
In this lab, you learn how to perform the following tasks:
- Configure Cloud Shell to run a multi-part Java application locally
- Use Apache Maven to launch Java applications in Cloud Shell
- Use curl and the Cloud Shell web preview to test connectivity to web applications running locally in Cloud Shell
Task 1. Bootstrap the application
- Run the backend locally
Run the backend application (guestbook-service).
cd ~/guestbook-service
./mvnw -q spring-boot:run -Dserver.port=8081
Test the service
curl http://localhost:8081/guestbookMessages
Post a new message.
curl -XPOST -H "content-type: application/json" \-d '{"name": "Ray", "message": "Hello"}' \http://localhost:8081/guestbookMessages
List all the messages.
curl http://localhost:8081/guestbookMessages
- Run the frontend locally
Make a copy of the initial version of the frontend application (guestbook-frontend).
cp -a ~/spring-cloud-gcp-guestbook/1-bootstrap/guestbook-frontend \~/guestbook-frontend
Run the frontend application.
cd ~/guestbook-frontend
./mvnw -q spring-boot:run
Task 2. Test the guestbook application
-
Web preview on port 8080
-
Use Cloud Shell to test the backend service
List all the calls to backend guestbook-service
API
curl -s http://localhost:8081/guestbookMessages
- Use
jp
to parse the JSON return text in given format.
curl -s http://localhost:8081/guestbookMessages \| jq -r '._embedded.guestbookMessages[] | {name: .name, message: .message}'
Spring Boot注解
SpringBoot之常用注解