Prepare Spring Boot application

Completed

In this unit, you learn how to prepare a Spring Boot application for deployment on Azure Container Apps. We use the popular Spring PetClinic sample application, which demonstrates the use of the Spring Framework and database access.

The Spring PetClinic is a simple web application that manages a list of veterinarians, their patients, and the visits those patients had. This application provides a practical way to understand key Spring Boot concepts while preparing a Spring Boot application for deployment to Azure.

Prerequisites

Clone the PetClinic repository

To get started with the PetClinic application, clone the Azure Container Apps Java Samples repository from GitHub by using the following command:

git clone https://github.com/Azure-Samples/azure-container-apps-java-samples.git

Run the application locally

Before deploying the PetClinic application, ensure that it runs successfully on your local machine by using the following steps:

  1. Navigate to the project directory by using the following command:

    cd azure-container-apps-java-samples/spring-petclinic/spring-petclinic/
    
  2. Initialize and update the pet-clinic Git submodule to the latest version by using the following command:

    git submodule update --init --recursive
    
  3. Build the project by using the following Maven command:

    ./mvnw clean install
    
  4. Run the application by using the following command:

    ./mvnw spring-boot:run
    
  5. After the application is running, you can access it locally via http://localhost:8080. You should see the Spring PetClinic interface, as shown in the following screenshot:

    Screenshot of the home page of the PetClinic application.

Database configuration

By default, the PetClinic application uses an in-memory H2 database that's automatically populated with data during startup. The H2 console is accessible at http://localhost:8080/h2-console, enabling you to inspect the database content via the URL jdbc:h2:mem:<UUID>. The specific UUID is displayed in the console when the application starts.