$ show spring-projects/spring-petclinic
This repository is the official Spring PetClinic sample application, a classic web application for managing a veterinary clinic's owners, pets, and visits. It is built as a Spring Boot monolith using Spring MVC, Spring Data JPA, Thymeleaf templating, and an H2 in-memory database by default, with optional MySQL and PostgreSQL backends. The application demonstrates a wide range of Spring Boot features including caching (JCache), internationalization (10+ languages), form validation, custom formatters, and comprehensive testing with JUnit 5, Mockito, and Testcontainers. It also includes a JMeter load test plan, Kubernetes deployment manifests, and CI/CD workflows for Maven and Gradle. The architecture follows a standard layered pattern: controllers handle HTTP requests, repositories provide data access via Spring Data JPA, and Thymeleaf templates render the UI. Domain models use a clean inheritance hierarchy (BaseEntity, NamedEntity, Person) to reduce duplication. The codebase is well-structured and serves as a reference for Spring Boot best practices, though it is intentionally a sample and not a production-ready system. It is actively maintained by the Spring team and tracks the latest Spring Boot releases. Key functional areas include owner management (CRUD with search), pet management (with duplicate name detection), visit scheduling (with future-date validation), and a veterinarian listing page. The application also includes a crash controller to demonstrate error handling and a welcome page. The code is clean, well-tested, and follows Spring conventions, making it a valuable learning resource for developers new to Spring Boot.
The LLM identified 4 files worth highlighting for reuse:
Provides a reusable base entity class with an auto-generated ID and an isNew() method that checks if the ID is null. This pattern reduces duplication across all domain entities (Owner, Pet, Visit, Vet, etc.) and can be extracted into any JPA-based project.
Implements Spring's Formatter interface to parse and print PetType objects from/to strings. It uses the PetTypeRepository to look up types by ID or name. This is a clean, reusable pattern for converting between domain objects and view representations in Spring MVC applications.
Implements Spring's Validator interface to validate pet form data, enforcing required fields (name, type, birth date) and name length constraints). It is self-contained and can be reused in any Spring Boot project needing custom validation logic beyond standard annotations.
A Thymeleaf fragment for rendering a form input field with label, error display, and placeholder. It uses Thymeleaf's th:field and th:errors attributes and can be reused across multiple forms across the application, reducing template duplication.