Distributed version of Spring Petclinic built with Spring Cloud
Java
2,219
406 commits
updated Oct 7, 2026
This project demonstrates how to split the classic Spring PetClinic sample application into microservices, with a Vue.js frontend and a Spring AI-powered chatbot. To achieve that goal, it relies on Spring Boot, Spring Cloud Gateway, Spring Cloud Circuit Breaker with Resilience4j, Spring Cloud Config, Micrometer Tracing with Zipkin, Prometheus and Grafana for monitoring, Spring Boot Admin, Chaos Monkey for Spring Boot, and the Eureka Service Discovery from the Spring Cloud Netflix technology stack.
Every microservice is a Spring Boot application and can be started locally using IDE or ../mvnw spring-boot:run command.
Please note that supporting services (Config and Discovery Server) must be started before any other application (Customers, Vets, Visits and API).
Startup of Tracing server, Admin server, Grafana and Prometheus is optional.
If everything goes well, you can access the following services at given location:
You can tell Config Server to use your local Git repository by using native Spring profile and setting
GIT_REPO environment variable, for example:
-Dspring.profiles.active=native -DGIT_REPO=/projects/spring-petclinic-microservices-config
In order to start entire infrastructure using Docker, you have to build images by executing
bash ./mvnw clean install -P buildDocker
This requires Docker or Docker desktop to be installed and running.
Alternatively you can also build all the images on Podman, which requires Podman or Podman Desktop to be installed and running.
./mvnw clean install -PbuildDocker -Dcontainer.executable=podman
By default, the Docker OCI image is build for an linux/amd64 platform.
For other architectures, you could change it by using the -Dcontainer.platform maven command line argument.
For instance, if you target container images for an Apple M2, you could use the command line with the linux/arm64 architecture:
./mvnw clean install -P buildDocker -Dcontainer.platform="linux/arm64"
Once images are ready, you can start them with a single command
docker compose up or podman-compose up.
Containers startup order is coordinated with the service_healthy condition of the Docker Compose depends-on expression
and the healthcheck of the service containers.
After starting services, it takes a while for API Gateway to be in sync with service registry,
so don't be scared of initial Spring Cloud Gateway timeouts. You can track services availability using Eureka dashboard
available by default at http://localhost:8761.
The main branch uses an Eclipse Temurin with Java 17 as Docker base image.
NOTE: Under MacOSX or Windows, make sure that the Docker VM has enough memory to run the microservices. The default settings
are usually not enough and make the docker-compose up painfully slow.
If you experience issues with running the system via docker-compose you can try running the ./scripts/run_all.sh script that will start the infrastructure
services via docker compose and all the Java based applications via standard nohup java -jar ... command.
The logs will be available under ${ROOT}/target/nameoftheapp.log.
By default the applications are started without the chaos-monkey profile. Pass the optional --chaos-monkey flag to enable it and interact with Spring Boot Chaos Monkey:
./scripts/run_all.sh --chaos-monkey
You can check out the README for more information about how to use the ./scripts/chaos/call_chaos.sh helper script to enable assaults.
Use ./scripts/stop_all.sh to stop all the Java applications and the docker-compose infrastructure containers started by run_all.sh.
See the presentation of the Spring Petclinic Framework version
A blog post introducing the Spring Petclinic Microsevices (french language)
You can then access petclinic here: http://localhost:8080/
This project consists of several microservices:
Each service has its own specific role and communicates via REST APIs.

Architecture diagram of the Spring Petclinic Microservices

Spring Petclinic integrates a Chatbot that allows you to interact with the application in a natural language. Here are some examples of what you could ask:

This spring-petclinic-genai-service microservice currently supports OpenAI (default) or Azure's OpenAI as the LLM provider.
In order to start the microservice, perform the following steps:
spring-ai-starter-model-openai dependency is enabled.
You can change it to spring-ai-starter-model-azure-openaiin the pom.xml.demo key, which OpenAI provides free of charge for demonstration purposes.
This demo key has a quota, is limited to the gpt-4o-mini model, and is intended solely for demonstration use.
With your own OpenAI account, you can test the gpt-4o model by modifying the deployment-name property of the application.yml file.export OPENAI_API_KEY="your_api_key_here"
export AZURE_OPENAI_ENDPOINT="https://your_resource.openai.azure.com"
export AZURE_OPENAI_KEY="your_api_key_here"
Our issue tracker is available here: https://github.com/spring-petclinic/spring-petclinic-microservices/issues
In its default configuration, Petclinic uses an in-memory database (HSQLDB) which gets populated at startup with data.
A similar setup is provided for MySql in case a persistent database configuration is needed.
Dependency for Connector/J, the MySQL JDBC driver is already included in the pom.xml files.
You may start a MySql database with docker:
docker run -e MYSQL_ROOT_PASSWORD=petclinic -e MYSQL_DATABASE=petclinic -p 3306:3306 mysql:8.4.5
or download and install the MySQL database (e.g., MySQL Community Server 8.4.5 LTS), which can be found here: https://dev.mysql.com/downloads/
To use a MySQL database, you have to start 3 microservices (visits-service, customers-service and vets-services)
with the mysql Spring profile. Add the --spring.profiles.active=mysql as program argument.
By default, at startup, database schema will be created and data will be populated.
You may also manually create the PetClinic database and data by executing the "db/mysql/{schema,data}.sql" scripts of each 3 microservices.
In the application.yml of the Configuration repository, set the initialization-mode to never.
If you are running the microservices with Docker, you have to add the mysql profile into the Dockerfile:
ENV SPRING_PROFILES_ACTIVE docker,mysql
In the mysql section of the application.yml from the Configuration repository, you have to change
the host and port of your MySQL JDBC connection string.
Grafana and Prometheus are included in the docker-compose.yml configuration, and the public facing applications
have been instrumented with MicroMeter to collect JVM and custom business metrics.
A JMeter load testing script is available to stress the application and generate metrics: petclinic_test_plan.jmx

Spring Petclinic Metrics Dashboard is available at the URL http://localhost:3030/d/69JXeR0iw/spring-petclinic-metrics.
You will find the JSON configuration file here: docker/grafana/dashboards/grafana-petclinic-dashboard.json.4701.Spring Boot registers a lot number of core metrics: JVM, CPU, Tomcat, Logback...
The Spring Boot auto-configuration enables the instrumentation of requests handled by Spring MVC.
All those three REST controllers OwnerResource, PetResource and VisitResource have been instrumented by the @Timed Micrometer annotation at class level.
customers-service application has the following custom metrics enabled:
petclinic.ownerpetclinic.petvisits-service application has the following custom metrics enabled:
petclinic.visit| Spring Cloud components | Resources |
|---|---|
| Configuration server | Config server properties and Configuration repository |
| Service Discovery | Eureka server and Service discovery client |
| API Gateway | Spring Cloud Gateway starter and Routing configuration |
| Docker Compose | Spring Boot with Docker guide and docker-compose file |
| Circuit Breaker | Resilience4j fallback method |
| Grafana / Prometheus Monitoring | Micrometer implementation, Spring Boot Actuator Production Ready Metrics |
| Front-end module | Files |
|---|---|
| Maven build | Maven dependencies for Vue, Vue Router, Bootstrap, DOMPurify, and Marked. Maven packages the frontend; no Node.js, NPM, or maven-frontend-plugin is required. |
| Vue JS | Standalone Vue modules use runtime templates and native browser imports in no-build mode. |
| Vue Router | Client-side routes use browser history for all application screens. |
| Static entry point | HTML host page mounts the Vue application and loads local WebJar assets. |
Docker images for linux/amd64 and linux/arm64 platforms have been published into DockerHub
in the springcommunity organization.
You can pull an image:
docker pull springcommunity/spring-petclinic-config-server
You may prefer to build then push images to your own Docker registry.
You need to define your target Docker registry.
Make sure you're already logged in by running docker login <endpoint> or docker login if you're just targeting Docker hub.
Setup the REPOSITORY_PREFIX env variable to target your Docker registry.
If you're targeting Docker hub, simple provide your username, for example:
export REPOSITORY_PREFIX=springcommunity
For other Docker registries, provide the full URL to your repository, for example:
export REPOSITORY_PREFIX=harbor.myregistry.com/petclinic
To push Docker image for the linux/amd64 and the linux/arm64 platform to your own registry, please use the command line:
mvn clean install -Dmaven.test.skip -P buildDocker -Ddocker.image.prefix=${REPOSITORY_PREFIX} -Dcontainer.build.extraarg="--push" -Dcontainer.platform="linux/amd64,linux/arm64"
The scripts/pushImages.sh and scripts/tagImages.sh shell scripts could also be used once you build your image with the buildDocker maven profile.
The scripts/tagImages.sh requires to declare the VERSION env variable.
There is a petclinic.css in spring-petclinic-api-gateway/src/main/resources/static/css.
It was generated from the petclinic.scss source, combined with the Bootstrap library.
If you make changes to the scss, or upgrade Bootstrap, you will need to re-compile the CSS resources
using the Maven profile css of the spring-petclinic-api-gatewaymodule.
cd spring-petclinic-api-gateway
mvn generate-resources -P css
The Spring Petclinic main branch in the main spring-projects
GitHub org is the "canonical" implementation, currently based on Spring Boot and Thymeleaf.
This spring-petclinic-microservices project is one of the several forks hosted in a special GitHub org: spring-petclinic. If you have a special interest in a different technology stack that could be used to implement the Pet Clinic then please join the community there.
The issue tracker is the preferred channel for bug reports, features requests and submitting pull requests.
For pull requests, editor preferences are available in the editor config for easy use in common text editors. Read more and download plugins at http://editorconfig.org.
109 followers · starred Feb 2022
40 followers · starred Mar 2021
58 followers · starred May 2021
14 followers · starred Mar 2022
Distributed version of Spring Petclinic built with Spring Cloud
Java
2,219
406 commits
updated Oct 7, 2026
This project demonstrates how to split the classic Spring PetClinic sample application into microservices, with a Vue.js frontend and a Spring AI-powered chatbot. To achieve that goal, it relies on Spring Boot, Spring Cloud Gateway, Spring Cloud Circuit Breaker with Resilience4j, Spring Cloud Config, Micrometer Tracing with Zipkin, Prometheus and Grafana for monitoring, Spring Boot Admin, Chaos Monkey for Spring Boot, and the Eureka Service Discovery from the Spring Cloud Netflix technology stack.
Every microservice is a Spring Boot application and can be started locally using IDE or ../mvnw spring-boot:run command.
Please note that supporting services (Config and Discovery Server) must be started before any other application (Customers, Vets, Visits and API).
Startup of Tracing server, Admin server, Grafana and Prometheus is optional.
If everything goes well, you can access the following services at given location:
You can tell Config Server to use your local Git repository by using native Spring profile and setting
GIT_REPO environment variable, for example:
-Dspring.profiles.active=native -DGIT_REPO=/projects/spring-petclinic-microservices-config
In order to start entire infrastructure using Docker, you have to build images by executing
bash ./mvnw clean install -P buildDocker
This requires Docker or Docker desktop to be installed and running.
Alternatively you can also build all the images on Podman, which requires Podman or Podman Desktop to be installed and running.
./mvnw clean install -PbuildDocker -Dcontainer.executable=podman
By default, the Docker OCI image is build for an linux/amd64 platform.
For other architectures, you could change it by using the -Dcontainer.platform maven command line argument.
For instance, if you target container images for an Apple M2, you could use the command line with the linux/arm64 architecture:
./mvnw clean install -P buildDocker -Dcontainer.platform="linux/arm64"
Once images are ready, you can start them with a single command
docker compose up or podman-compose up.
Containers startup order is coordinated with the service_healthy condition of the Docker Compose depends-on expression
and the healthcheck of the service containers.
After starting services, it takes a while for API Gateway to be in sync with service registry,
so don't be scared of initial Spring Cloud Gateway timeouts. You can track services availability using Eureka dashboard
available by default at http://localhost:8761.
The main branch uses an Eclipse Temurin with Java 17 as Docker base image.
NOTE: Under MacOSX or Windows, make sure that the Docker VM has enough memory to run the microservices. The default settings
are usually not enough and make the docker-compose up painfully slow.
If you experience issues with running the system via docker-compose you can try running the ./scripts/run_all.sh script that will start the infrastructure
services via docker compose and all the Java based applications via standard nohup java -jar ... command.
The logs will be available under ${ROOT}/target/nameoftheapp.log.
By default the applications are started without the chaos-monkey profile. Pass the optional --chaos-monkey flag to enable it and interact with Spring Boot Chaos Monkey:
./scripts/run_all.sh --chaos-monkey
You can check out the README for more information about how to use the ./scripts/chaos/call_chaos.sh helper script to enable assaults.
Use ./scripts/stop_all.sh to stop all the Java applications and the docker-compose infrastructure containers started by run_all.sh.
See the presentation of the Spring Petclinic Framework version
A blog post introducing the Spring Petclinic Microsevices (french language)
You can then access petclinic here: http://localhost:8080/
This project consists of several microservices:
Each service has its own specific role and communicates via REST APIs.

Architecture diagram of the Spring Petclinic Microservices

Spring Petclinic integrates a Chatbot that allows you to interact with the application in a natural language. Here are some examples of what you could ask:

This spring-petclinic-genai-service microservice currently supports OpenAI (default) or Azure's OpenAI as the LLM provider.
In order to start the microservice, perform the following steps:
spring-ai-starter-model-openai dependency is enabled.
You can change it to spring-ai-starter-model-azure-openaiin the pom.xml.demo key, which OpenAI provides free of charge for demonstration purposes.
This demo key has a quota, is limited to the gpt-4o-mini model, and is intended solely for demonstration use.
With your own OpenAI account, you can test the gpt-4o model by modifying the deployment-name property of the application.yml file.export OPENAI_API_KEY="your_api_key_here"
export AZURE_OPENAI_ENDPOINT="https://your_resource.openai.azure.com"
export AZURE_OPENAI_KEY="your_api_key_here"
Our issue tracker is available here: https://github.com/spring-petclinic/spring-petclinic-microservices/issues
In its default configuration, Petclinic uses an in-memory database (HSQLDB) which gets populated at startup with data.
A similar setup is provided for MySql in case a persistent database configuration is needed.
Dependency for Connector/J, the MySQL JDBC driver is already included in the pom.xml files.
You may start a MySql database with docker:
docker run -e MYSQL_ROOT_PASSWORD=petclinic -e MYSQL_DATABASE=petclinic -p 3306:3306 mysql:8.4.5
or download and install the MySQL database (e.g., MySQL Community Server 8.4.5 LTS), which can be found here: https://dev.mysql.com/downloads/
To use a MySQL database, you have to start 3 microservices (visits-service, customers-service and vets-services)
with the mysql Spring profile. Add the --spring.profiles.active=mysql as program argument.
By default, at startup, database schema will be created and data will be populated.
You may also manually create the PetClinic database and data by executing the "db/mysql/{schema,data}.sql" scripts of each 3 microservices.
In the application.yml of the Configuration repository, set the initialization-mode to never.
If you are running the microservices with Docker, you have to add the mysql profile into the Dockerfile:
ENV SPRING_PROFILES_ACTIVE docker,mysql
In the mysql section of the application.yml from the Configuration repository, you have to change
the host and port of your MySQL JDBC connection string.
Grafana and Prometheus are included in the docker-compose.yml configuration, and the public facing applications
have been instrumented with MicroMeter to collect JVM and custom business metrics.
A JMeter load testing script is available to stress the application and generate metrics: petclinic_test_plan.jmx

Spring Petclinic Metrics Dashboard is available at the URL http://localhost:3030/d/69JXeR0iw/spring-petclinic-metrics.
You will find the JSON configuration file here: docker/grafana/dashboards/grafana-petclinic-dashboard.json.4701.Spring Boot registers a lot number of core metrics: JVM, CPU, Tomcat, Logback...
The Spring Boot auto-configuration enables the instrumentation of requests handled by Spring MVC.
All those three REST controllers OwnerResource, PetResource and VisitResource have been instrumented by the @Timed Micrometer annotation at class level.
customers-service application has the following custom metrics enabled:
petclinic.ownerpetclinic.petvisits-service application has the following custom metrics enabled:
petclinic.visit| Spring Cloud components | Resources |
|---|---|
| Configuration server | Config server properties and Configuration repository |
| Service Discovery | Eureka server and Service discovery client |
| API Gateway | Spring Cloud Gateway starter and Routing configuration |
| Docker Compose | Spring Boot with Docker guide and docker-compose file |
| Circuit Breaker | Resilience4j fallback method |
| Grafana / Prometheus Monitoring | Micrometer implementation, Spring Boot Actuator Production Ready Metrics |
| Front-end module | Files |
|---|---|
| Maven build | Maven dependencies for Vue, Vue Router, Bootstrap, DOMPurify, and Marked. Maven packages the frontend; no Node.js, NPM, or maven-frontend-plugin is required. |
| Vue JS | Standalone Vue modules use runtime templates and native browser imports in no-build mode. |
| Vue Router | Client-side routes use browser history for all application screens. |
| Static entry point | HTML host page mounts the Vue application and loads local WebJar assets. |
Docker images for linux/amd64 and linux/arm64 platforms have been published into DockerHub
in the springcommunity organization.
You can pull an image:
docker pull springcommunity/spring-petclinic-config-server
You may prefer to build then push images to your own Docker registry.
You need to define your target Docker registry.
Make sure you're already logged in by running docker login <endpoint> or docker login if you're just targeting Docker hub.
Setup the REPOSITORY_PREFIX env variable to target your Docker registry.
If you're targeting Docker hub, simple provide your username, for example:
export REPOSITORY_PREFIX=springcommunity
For other Docker registries, provide the full URL to your repository, for example:
export REPOSITORY_PREFIX=harbor.myregistry.com/petclinic
To push Docker image for the linux/amd64 and the linux/arm64 platform to your own registry, please use the command line:
mvn clean install -Dmaven.test.skip -P buildDocker -Ddocker.image.prefix=${REPOSITORY_PREFIX} -Dcontainer.build.extraarg="--push" -Dcontainer.platform="linux/amd64,linux/arm64"
The scripts/pushImages.sh and scripts/tagImages.sh shell scripts could also be used once you build your image with the buildDocker maven profile.
The scripts/tagImages.sh requires to declare the VERSION env variable.
There is a petclinic.css in spring-petclinic-api-gateway/src/main/resources/static/css.
It was generated from the petclinic.scss source, combined with the Bootstrap library.
If you make changes to the scss, or upgrade Bootstrap, you will need to re-compile the CSS resources
using the Maven profile css of the spring-petclinic-api-gatewaymodule.
cd spring-petclinic-api-gateway
mvn generate-resources -P css
The Spring Petclinic main branch in the main spring-projects
GitHub org is the "canonical" implementation, currently based on Spring Boot and Thymeleaf.
This spring-petclinic-microservices project is one of the several forks hosted in a special GitHub org: spring-petclinic. If you have a special interest in a different technology stack that could be used to implement the Pet Clinic then please join the community there.
The issue tracker is the preferred channel for bug reports, features requests and submitting pull requests.
For pull requests, editor preferences are available in the editor config for easy use in common text editors. Read more and download plugins at http://editorconfig.org.
109 followers · starred Feb 2022
40 followers · starred Mar 2021
58 followers · starred May 2021
14 followers · starred Mar 2022