A sample Spring-based application
Find a file
2023-01-19 22:01:04 +05:30
.devcontainer Tweak devcontainer so java and permissions work 2022-09-27 17:14:13 +00:00
.github/workflows Change CI step names 2022-09-15 07:47:28 +00:00
.mvn/wrapper Upgrade to Maven 3.8.2 2021-08-26 16:29:34 +02:00
docker-kubernetes changed welcome message 2023-01-09 19:32:59 +05:30
gradle/wrapper Upgrade to Gradle 7.5.1 and to Spring Boot 2.7.3 2022-09-05 11:48:27 +00:00
helm-ver/tanzu-se-petclinic changed welcome message 2023-01-09 19:32:59 +05:30
src changed welcome message 2023-01-19 22:01:04 +05:30
.editorconfig Change EditorConfig to reflect some files are indented with 2 spaces 2020-06-13 14:03:04 +01:00
.gitignore Add devcontainer and gitpod 2022-06-09 11:24:17 +01:00
.gitpod.yml Add devcontainer and gitpod 2022-06-09 11:24:17 +01:00
.springjavaformatconfig Add support and CI tests for Java 8 2022-09-14 17:05:06 +00:00
build.gradle Upgrade to Gradle 7.5.1 and to Spring Boot 2.7.3 2022-09-05 11:48:27 +00:00
docker-compose.yml Add support for PostgreSQL 2021-12-07 16:55:01 +00:00
gradlew Upgrade to Gradle 7.5.1 and to Spring Boot 2.7.3 2022-09-05 11:48:27 +00:00
gradlew.bat Make build work with Gradle 2021-12-16 11:25:09 +00:00
LICENSE.txt Add license file 2021-10-05 16:49:36 +01:00
mvnw Upgrade to Maven 3.6.3 and Maven Wrapper 0.5.6 2020-06-13 14:02:26 +01:00
mvnw.cmd Upgrade to Maven 3.6.3 and Maven Wrapper 0.5.6 2020-06-13 14:02:26 +01:00
pom.xml Upgrade to Gradle 7.5.1 and to Spring Boot 2.7.3 2022-09-05 11:48:27 +00:00
readme.md updated .md file 2022-10-16 09:40:10 +05:30
settings.gradle Make build work with Gradle 2021-12-16 11:25:09 +00:00

Spring PetClinic Sample Application Build Status

Understanding the Spring Petclinic application with a few diagrams

See the presentation here

Running petclinic locally

Petclinic is a Spring Boot application built using Maven or Gradle. You can build a jar file and run it from the command line (it should work just as well with Java 11 or newer):

git clone https://github.com/i386kernel/tanzu-SE-spring-petclinic.git
cd spring-petclinic
./mvnw package
java -jar target/*.jar

You can then access petclinic here: http://localhost:8080/

Or you can run it from Maven directly using the Spring Boot Maven plugin. If you do this it will pick up changes that you make in the project immediately (changes to Java source files require a compile as well - most people use an IDE for this):

./mvnw spring-boot:run

NOTE: Windows users should set git config core.autocrlf true to avoid format assertions failing the build (use --global to set that flag globally).

NOTE: If you prefer to use Gradle, you can build the app using ./gradlew build and look for the jar file in build/libs.

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:

./mvnw spring-boot:build-image

Run in Docker

docker run -p 8080:8080 -d spring-petclinic:2.7.3

Run in Kubernetes

kubectl apply -f https://raw.githubusercontent.com/i386kernel/tanzu-SE-spring-petclinic/main/docker-kubernetes/kube-manifest.yml

Database configuration

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

A similar setup is provided for MySQL and PostgreSQL in case a persistent database configuration is needed. Note that whenever the database type is changed, the app needs to be run with a different profile: spring.profiles.active=mysql for MySQL or spring.profiles.active=postgres for PostgreSQL.

You could start MySQL or PostgreSQL locally with whatever installer works for your OS, or with docker:

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

or

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

Further documentation is provided for MySQL and for PostgreSQL.