Skip to content

isa-group/petclinic-react

Repository files navigation

Spring PetClinic Sample Application

This is a fork of https://github.com/spring-projects/spring-petclinic to be used for the Pricing4SaaS research. The main changes that have been performed were:

  • Trimming several parts of the application to keep the example low
  • Redesigned the frontend using React as the main framework

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. You can build a jar file and run it from the command line:

git clone https://github.com/isa-group/petclinic-react
cd petclinic-react
mvn -f ./pom.xml clean package -Dmaven.test.skip=true
java -jar target/petclinic.jar

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

petclinic-screenshot

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):

mvn spring-boot:run

Running petclinic with docker

If you have the docker engine installed on your machine, you can easily run petclinic using the following command:

git clone https://github.com/isa-group/petclinic-react
cd petclinic-react
docker-compose up -d

This operation will create a group of three containers:

  • A MySQL container that will be used to store the data
  • The spring-boot REST API that will take the backend role, and is connected to MySQL
  • The React frontend

Once the containers are up and running, you can access petclinic through: http://localhost

Credentials to run the demo

Username Password Role
admin1 4dm1n ADMIN
vet1 v3t VET
owner1 0wn3r OWNER
clinicOwner1 cl1n1c0wn3r CLINIC_OWNER

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

Our issue tracker is available here: https://github.com/gii-is-DP1/spring-petclinic/issues

Database configuration

In its default configuration, Petclinic uses an in-memory database (H2) which gets populated at startup with data.

Steps:

  1. On the command line
git clone https://github.com/gii-is-DP1/spring-petclinic.git
  1. Inside Eclipse or STS
File -> Import -> Maven -> Existing Maven project

Then either build on the command line ./mvnw generate-resources or using the Eclipse launcher (right click on project and Run As -> Maven install) to generate the css. Run the application main method by right clicking on it and choosing Run As -> Java Application.

  1. Inside IntelliJ IDEA

In the main menu, choose File -> Open and select the Petclinic pom.xml. Click on the Open button.

CSS files are generated from the Maven build. You can either build them on the command line ./mvnw generate-resources or right click on the spring-petclinic project then Maven -> Generates sources and Update Folders.

A run configuration named PetClinicApplication should have been created for you if you're using a recent Ultimate version. Otherwise, run the application by right clicking on the PetClinicApplication main class and choosing Run 'PetClinicApplication'.

  1. Navigate to Petclinic

Visit http://localhost:8080 in your browser.

Looking for something in particular?

Spring Boot Configuration Class or Java property files
The Main Class PetClinicApplication
Properties Files application.properties
Caching CacheConfiguration

Interesting Spring Petclinic branches and forks

The Spring Petclinic master branch in the main spring-projects GitHub org is the "canonical" implementation, currently based on Spring Boot and Thymeleaf. There are quite a few forks 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.

Contributing

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 https://editorconfig.org. If you have not previously done so, please fill out and submit the Contributor License Agreement.

License

The Spring PetClinic sample application is released under version 2.0 of the Apache License.