Instrucciones y requisitos de configuración del lab
Protege tu cuenta y tu progreso. Usa siempre una ventana de navegador privada y las credenciales del lab para ejecutarlo.

JAVAMS01 Bootstrapping the Application Frontend and Backend

Lab 1 hora universal_currency_alt 5 créditos show_chart Introductorio
info Es posible que este lab incorpore herramientas de IA para facilitar tu aprendizaje.
Este contenido aún no está optimizado para dispositivos móviles.
Para obtener la mejor experiencia, visítanos en una computadora de escritorio con un vínculo que te enviaremos por correo electrónico.

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.

Antes de comenzar

  1. Los labs crean un proyecto de Google Cloud y recursos por un tiempo determinado
  2. .
  3. Los labs tienen un límite de tiempo y no tienen la función de pausa. Si finalizas el lab, deberás reiniciarlo desde el principio.
  4. En la parte superior izquierda de la pantalla, haz clic en Comenzar lab para empezar

Usa la navegación privada

  1. Copia el nombre de usuario y la contraseña proporcionados para el lab
  2. Haz clic en Abrir la consola en modo privado

Accede a la consola

  1. Accede con tus credenciales del lab. Si usas otras credenciales, se generarán errores o se incurrirá en cargos.
  2. Acepta las condiciones y omite la página de recursos de recuperación
  3. No hagas clic en Finalizar lab, a menos que lo hayas terminado o quieras reiniciarlo, ya que se borrará tu trabajo y se quitará el proyecto

Este contenido no está disponible en este momento

Te enviaremos una notificación por correo electrónico cuando esté disponible

¡Genial!

Nos comunicaremos contigo por correo electrónico si está disponible

Un lab a la vez

Confirma para finalizar todos los labs existentes y comenzar este

Usa la navegación privada para ejecutar el lab

Usar una ventana de incógnito o de navegación privada es la mejor forma de ejecutar este lab. Así evitarás cualquier conflicto entre tu cuenta personal y la cuenta de estudiante, lo que podría generar cargos adicionales en tu cuenta personal.