spring-projects /spring-petclinic

A sample Spring-based application

★ 9,657⑂ 31,171👁 360⑃ 2,320● 396▤ 0
CSSApache-2.0Created 2013-01-09
+3
Daily
9,657
stars
31,171
forks
360
watchers
2,320
prs
396
issues
0
releases

README

Spring PetClinic Sample Application 

 

 Understanding the Spring Petclinic application with a few diagrams

See the presentation here:  
Spring Petclinic Sample Application (legacy slides)

 Note: These slides refer to a legacy, pre–Spring Boot version of Petclinic and may not reflect the current Spring Boot–based implementation.  
 For up-to-date information, please refer to this repository and its documentation.


 Run Petclinic locally

Spring Petclinic is a Spring Boot application built using Maven or Gradle.
Java 17 or later is required for the build, and the application can run with Java 17 or newer.

You first need to clone the project locally:

bash
git clone https://github.com/spring-projects/spring-petclinic.git
cd spring-petclinic

If you are using Maven, you can start the application on the command-line as follows:

bash
./mvnw spring-boot:run

With Gradle, the command is as follows:

bash
./gradlew bootRun


You can then access the Petclinic at .



You can, of course, run Petclinic in your favorite IDE.
See below for more details.

 Building a Container

There is no Dockerfile in this project. You can build a container image (if you have a docker daemon) using the Spring Boot build plugin:

bash
./mvnw spring-boot:build-image


 Running the Container Image

bash
docker images | grep petclinic
docker run -p 8080:8080 docker.io/library/spring-petclinic:latest


 In case you find a bug/suggested improvement for Spring Petclinic

Our issue tracker is available here.

 Database configuration

In its default configuration, Petclinic uses an in-memory database (H2) which
gets populated at startup with data. The h2 console is exposed at http://localhost:8080/h2-console,
and it is possible to inspect the content of the database using the jdbc:h2:mem: URL. The UUID is printed at startup to the console.

A similar setup is provided for MySQL and PostgreSQL if a persistent database configuration is needed. Note that whenever the database type changes, the app needs to run with a different profile: spring.profiles.active=mysql for MySQL or spring.profiles.active=postgres for PostgreSQL. See the Spring Boot documentation for more detail on how to set the active profile.

You can start MySQL or PostgreSQL locally with whatever installer works for your OS or use docker:

bash
docker run -e MYSQL_USER=petclinic -e MYSQL_PASSWORD=petclinic -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=petclinic -p 3306:3306 mysql:9.7


or

bash
docker run -e POSTGRES_USER=petclinic -e POSTGRES_PASSWORD=petclinic -e POSTGRES_DB=petclinic -p 5432:5432 postgres:18.4


Further documentation is provided for MySQL
and PostgreSQL.

Instead of vanilla docker you can also use the provided docker-compose.yml file to start the database containers. Each one has a service named after the Spring profile:

bash
docker compose up mysql


or

bash
docker compose up postgres


 Test Applications

At development time we recommend you use the test applications set up as main() methods

Top issues

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON