실습 설정 안내 및 요구사항
계정과 진행 상황을 보호하세요. 이 실습을 실행하려면 항상 시크릿 브라우저 창과 실습 사용자 인증 정보를 사용하세요.

JAVAMS01 Bootstrapping the Application Frontend and Backend

실습 1시간 universal_currency_alt 크레딧 5개 show_chart 입문
info 이 실습에는 학습을 지원하는 AI 도구가 통합되어 있을 수 있습니다.
이 콘텐츠는 아직 휴대기기에 최적화되지 않음
최상의 경험을 위해 데스크톱 컴퓨터에서 이메일로 전송된 링크를 사용하여 방문하세요.

Overview

In this series of labs, you take a demo microservices Java application built with the Spring framework and modify it to use an external database server. You adopt some of the best practices for tracing, configuration management, and integration with other services using integration patterns.

When implementing such techniques in a traditional on-premises environment, you have to build and manage these servers and service capabilities yourself.

But what do you do when you move to the cloud? Going cloud native is not only about replicating the architectures that you have to implement in your own data center, simply substituting virtual machine-based workloads for bare-metal workloads. Cloud-native applications can adopt the fully managed cloud services and platforms that require little or no manual operational overhead.

In these labs, you learn how to replace the external dependencies that you would otherwise need to maintain and operate yourself with fully managed services on Google Cloud.

Through the use of Spring Cloud, Google Cloud components, and preconfigured Spring Boot starters, you can quickly replace RDBMs like MySQL with Cloud SQL, messaging pipeline services like RabbitMQ with Pub/Sub, distributed trace stores like Zipkin with Cloud Trace, and centralized configuration server services with Cloud Runtime Configuration API.

You first deploy and test the application in Cloud Shell, starting with this lab, where you bring the application up by running the two microservices components in separate Cloud Shell console tabs.

In later labs in this series, you deploy the application components to App Engine and Kubernetes Engine and explore how to use Cloud Trace to debug and monitor your application when it is deployed to those services.

Objectives

In this lab, you will 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.

Setup and requirements

How to start your lab and sign in to the Console

  1. Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is a panel populated with the temporary credentials that you must use for this lab.

    Credentials panel

  2. Copy the username, and then click Open Google Console. The lab spins up resources, and then opens another tab that shows the Choose an account page.

    Note: Open the tabs in separate windows, side-by-side.
  3. On the Choose an account page, click Use Another Account. The Sign in page opens.

    Choose an account dialog box with Use Another Account option highlighted

  4. Paste the username that you copied from the Connection Details panel. Then copy and paste the password.

Note: You must use the credentials from the Connection Details panel. Do not use your Google Skills credentials. If you have your own Google Cloud account, do not use it for this lab (avoids incurring charges).
  1. Click through the subsequent pages:
  • Accept the terms and conditions.
  • Do not add recovery options or two-factor authentication (because this is a temporary account).
  • Do not sign up for free trials.

After a few moments, the Cloud console opens in this tab.

Note: You can view the menu with a list of Google Cloud Products and Services by clicking the Navigation menu at the top-left. Cloud Console Menu

Activate Google Cloud Shell

Google Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud.

Google Cloud Shell provides command-line access to your Google Cloud resources.

  1. In Cloud console, on the top right toolbar, click the Open Cloud Shell button.

    Highlighted Cloud Shell icon

  2. Click Continue.

It takes a few moments to provision and connect to the environment. When you are connected, you are already authenticated, and the project is set to your PROJECT_ID. For example:

Project ID highlighted in the Cloud Shell Terminal

gcloud is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.

  • You can list the active account name with this command:
gcloud auth list

Output:

Credentialed accounts: - @.com (active)

Example output:

Credentialed accounts: - google1623327_student@qwiklabs.net
  • You can list the project ID with this command:
gcloud config list project

Output:

[core] project =

Example output:

[core] project = qwiklabs-gcp-44776a13dea667a6 Note: Full documentation of gcloud is available in the gcloud CLI overview guide .

Task 1. Bootstrap the application

In this task, you will clone the source repository for the demo application that is used throughout these labs.

The demo application has two parts:

  • A frontend application (guestbook-frontend) that manages the user interface presented in a web browser.
  • A backend service application (guestbook-service) that processes the data and manages the messaging and database interfaces.

Clone the demo application

  • In Cloud Shell, clone the demo application by executing the following command:
cd ~/ git clone --depth=1 https://github.com/GoogleCloudPlatform/training-data-analyst ln -s ~/training-data-analyst/courses/java-microservices/spring-cloud-gcp-guestbook ~/spring-cloud-gcp-guestbook

Run the backend locally

To run, test, and use the backend locally, perform the following steps:

  1. To make a copy of the initial version of the backend application (guestbook-service), execute the following command:
cp -a ~/spring-cloud-gcp-guestbook/1-bootstrap/guestbook-service ~/guestbook-service
  1. To run the backend application, execute the following command:
cd ~/guestbook-service ./mvnw -q spring-boot:run -Dserver.port=8081
  1. Open a new Cloud Shell session tab to test the backend application by clicking the plus (+) icon to the right of the title tab for the initial Cloud Shell session.

This action opens a second Cloud Shell console to the same virtual machine.

Virtual machine Cloud Shell instance

  1. While the backend application (guestbook-service) is still running, test the service by executing the following command in the second Cloud Shell tab:
curl http://localhost:8081/guestbookMessages
  1. Post a new message:
curl -XPOST -H "content-type: application/json" \ -d '{"name": "Ray", "message": "Hello"}' \ http://localhost:8081/guestbookMessages
  1. List all the messages:
curl http://localhost:8081/guestbookMessages

Run the frontend locally

To run the frontend locally, perform the following steps:

  1. To make a copy of the initial version of the frontend application (guestbook-frontend), execute the following command:
cp -a ~/spring-cloud-gcp-guestbook/1-bootstrap/guestbook-frontend ~/guestbook-frontend
  1. To run the frontend application, execute the following command:
cd ~/guestbook-frontend ./mvnw -q spring-boot:run

The frontend web application launches on port 8080.

Task 2. Test the guestbook application

In this task, you will test the demo application. The demo application is a simple Java application composed of a microservices backend and a frontend consuming it. You extend this simple application in later labs to leverage various Google Cloud services. You will eventually deploy it to the cloud, using both App Engine and Google Kubernetes Engine.

Access the frontend application through the Cloud Shell web preview

To access and use the frontend application through the web preview, perform the following steps:

  1. Click the Web Preview (Web preview icon button) icon.
  2. Select Preview on port 8080 to access the application on port 8080.

Application previewed on port 8080

A new browser tab displays the connection to the frontend application.

  1. For Your name, type your name.

Your name text field

  1. For Message, type a message.
  2. Click Post to continue.

The messages are listed below the message input section.

A sample message of "Hi" displays for Ray

Use Cloud Shell to test the backend service

To use Cloud Shell to test the backend service, perform the following steps.

  1. Open a third Cloud Shell tab.
  2. In the new shell tab, list all the messages that you added through a call to the backend guestbook-service API by executing the following command:
curl -s http://localhost:8081/guestbookMessages
  1. To use jq to parse the JSON return text, execute the following command.

For example, the following command prints out only the messages.

curl -s http://localhost:8081/guestbookMessages \ | jq -r '._embedded.guestbookMessages[] | {name: .name, message: .message}'

Congratulations!

In this lab, you have configured Cloud Shell to run multi-part Java applications locally. Next, you used Maven to launch Java applications in the Cloud shell. Finally, you used curl and the Cloud Shell web preview to test connectivity to web applications running locally in Cloud Shell.

End your lab

When you have completed your lab, click End Lab. Google Skills removes the resources you’ve used and cleans the account for you.

You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.

The number of stars indicates the following:

  • 1 star = Very dissatisfied
  • 2 stars = Dissatisfied
  • 3 stars = Neutral
  • 4 stars = Satisfied
  • 5 stars = Very satisfied

You can close the dialog box if you don't want to provide feedback.

For feedback, suggestions, or corrections, please use the Support tab.

Copyright 2026 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.

시작하기 전에

  1. 실습에서는 정해진 기간 동안 Google Cloud 프로젝트와 리소스를 만듭니다.
  2. 실습에는 시간 제한이 있으며 일시중지 기능이 없습니다. 실습을 종료하면 처음부터 다시 시작해야 합니다.
  3. 화면 왼쪽 상단에서 실습 시작을 클릭하여 시작합니다.

시크릿 브라우징 사용

  1. 실습에 입력한 사용자 이름비밀번호를 복사합니다.
  2. 비공개 모드에서 콘솔 열기를 클릭합니다.

콘솔에 로그인

    실습 사용자 인증 정보를 사용하여
  1. 로그인합니다. 다른 사용자 인증 정보를 사용하면 오류가 발생하거나 요금이 부과될 수 있습니다.
  2. 약관에 동의하고 리소스 복구 페이지를 건너뜁니다.
  3. 실습을 완료했거나 다시 시작하려고 하는 경우가 아니면 실습 종료를 클릭하지 마세요. 이 버튼을 클릭하면 작업 내용이 지워지고 프로젝트가 삭제됩니다.

현재 이 콘텐츠를 이용할 수 없습니다

이용할 수 있게 되면 이메일로 알려드리겠습니다.

감사합니다

이용할 수 있게 되면 이메일로 알려드리겠습니다.

한 번에 실습 1개만 가능

모든 기존 실습을 종료하고 이 실습을 시작할지 확인하세요.

시크릿 브라우징을 사용하여 실습 실행하기

이 실습을 실행하는 가장 좋은 방법은 시크릿 모드 또는 시크릿 브라우저 창을 사용하는 것입니다. 개인 계정과 학생 계정 간의 충돌로 개인 계정에 추가 요금이 발생하는 일을 방지해 줍니다.