• Stars
    star
    345
  • Rank 122,750 (Top 3 %)
  • Language
    Kotlin
  • License
    Apache License 2.0
  • Created about 7 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Kotlin version of Spring Petclinic

Kotlin version of the Spring PetClinic Sample Application

Java CI with Gradle Docker pulls

This is a Kotlin version of the spring-petclinic Application.

Technologies used

  • Language: Kotlin
  • Core framework: Spring Boot 3 with Spring Framework 6 Kotlin support
  • Server: Apache Tomcat
  • Web framework: Spring MVC
  • Templates: Thymeleaf and Bootstrap 5
  • Persistence : Spring Data JPA
  • Databases: H2 and MySQL both supported
  • Build: Gradle Script with the Kotlin DSL
  • Testing: Junit 5, Mockito and AssertJ

Running petclinic locally

With gradle command line

git clone https://github.com/spring-petclinic/spring-petclinic-kotlin.git
cd spring-petclinic-kotlin
./gradlew bootRun

With Docker

docker run -p 8080:8080 springcommunity/spring-petclinic-kotlin

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

petclinic-screenshot

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:{uuid} url (the uuid param could be find in the startup logs).

A similar setup is provided for MySql in case a persistent database configuration is needed. Note that whenever the database type is changed, the data-access.properties file needs to be updated and the mysql-connector-java artifact from the pom.xml needs to be uncommented.

You could start a MySql database 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

Further documentation is provided here.

Looking for something in particular?

Features Class, files or Java property files
The Main Class PetClinicApplication
Properties configuration file application.properties
Gradle build script with Kotlin DSL build.gradle.kts
Caching Configuration CacheConfig

Import and run the project in IntelliJ IDEA

  • Make sure you have at least IntelliJ IDEA 2017.2 and IDEA Kotlin plugin 1.1.60+ (menu Tools -> Kotlin -> configure Kotlin Plugin Updates -> make sure "Stable" channel is selected -> check for updates now -> restart IDE after the update)
  • Import it in IDEA as a Gradle project
    • Go to the menu "File -> New -> Project from Existing Sources... "
    • Select the spring-petclinic-kotlin directory then choose "Import the project from Gradle"
    • Select the "Use gradle wrapper task configuration" radio button
  • In IntelliJ IDEA, right click on PetClinicApplication.kt then "Run..." or "Debug..."
  • Open http://localhost:8080/ in your browser

Documentation

Publishing a Docker image

This application uses Google Jib to build an optimized Docker image into the Docker Hub repository. The build.gradle.kts has been configured to publish the image with a the springcommunity/spring-petclinic-kotlin image name.

Build and push the container image of Petclinic to the Docker Hub registry:

gradle jib -Djib.to.auth.username=<username> -Djib.to.auth.password=<password>

Interesting Spring Petclinic forks

The Spring Petclinic master branch in the main spring-projects GitHub org is the "canonical" implementation, currently based on Spring Boot and Thymeleaf.

This [spring-petclinic-kotlin][] 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.

Interaction with other open source projects

One of the best parts about working on the Spring Petclinic application is that we have the opportunity to work in direct contact with many Open Source projects. We found some bugs/suggested improvements on various topics such as Spring, Spring Data, Bean Validation and even Eclipse! In many cases, they've been fixed/implemented in just a few days. Here is a list of them:

Name Issue
Spring JDBC: simplify usage of NamedParameterJdbcTemplate SPR-10256 and SPR-10257
Bean Validation / Hibernate Validator: simplify Maven dependencies and backward compatibility HV-790 and HV-792
Spring Data: provide more flexibility when working with JPQL queries DATAJPA-292

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 http://editorconfig.org.

More Repositories

1

spring-petclinic-microservices

Distributed version of Spring Petclinic built with Spring Cloud
Java
1,622
star
2

spring-petclinic-rest

REST version of the Spring Petclinic sample application
Java
459
star
3

spring-framework-petclinic

A Spring Framework application based on JSP, Spring MVC, Spring Data JPA, Hibernate and JDBC
CSS
360
star
4

spring-petclinic-reactjs

ReactJS (with TypeScript) and Spring Boot version of the Spring Petclinic sample application
Java
269
star
5

spring-petclinic-angular

Angular 16 version of the Spring Petclinic sample application (frontend)
TypeScript
199
star
6

spring-petclinic-graphql

PetClinic Example based on GraphQL
CSS
191
star
7

spring-petclinic-cloud

Fork of the Spring Cloud Microservices project packaged to be deployed on several Cloud platforms: Kubernetes and Cloud Foundry
Java
135
star
8

spring-petclinic-data-jdbc

Spring Data JDBC version of the Spring Boot Petclinic
Java
102
star
9

spring-petclinic-reactive

Reactive version of Spring PetClinic sample application based on Spring Webflux and Cassandra
Java
71
star
10

spring-petclinic-angularjs

AngularJS 1 and Spring Boot 2 version of the Spring Petclinic sample application
Java
71
star
11

spring-petclinic-microservices-config

Configuration repository for distributed Spring Petclinic application
44
star
12

spring-petclinic-htmx

Htmx version of the Spring PetClinic sample application
CSS
27
star
13

spring-petclinic-hilla

Hilla implementation of the Spring PetClinic sample
Java
8
star
14

spring-petclinic-vaadin-flow

Vaadin Flow implementation of the Spring PetClinic sample
Java
8
star
15

spring-petclinic.github.io

Spring Petclinic organisation website
CSS
7
star
16

spring-petclinic-mustache

Classic Spring PetClinic with Mustache templates
CSS
4
star
17

spring-petclinic-cloud-config

Configuration repository for the Spring Petclinic Cloud project
2
star