Micronaut PetClinic sample application built with Micronaut 4.
A modern Micronaut PetClinic example and implementation of the classic Spring PetClinic, demonstrating how to build fast, cloud-native Java applications using the Micronaut framework.
Micronaut PetClinic is a reference Micronaut application that showcases how to build a real-world veterinary clinic system using Java and Micronaut.
This Micronaut PetClinic app allows you to:
- Manage pet owners (create, update, search)
- Register pets for owners
- Schedule veterinary visits
- View veterinarians and their specialties
- Switch between English, Spanish, and German
- Java 21 or higher
- Maven 3.9+ (or use the included wrapper)
- Gradle 9+ (or use the included wrapper)
- Docker (optional, for databases)
# Clone and run with in-memory H2 database (Maven)
git clone https://github.com/micronaut-projects/micronaut-petclinic.git
cd micronaut-petclinic
./mvnw mn:run
# Gradle alternative
./gradlew rundocker-compose --profile oracle upNote: The default configuration uses an ARM64 image for Apple Silicon Macs. For x86/AMD64 machines, update the image in
docker-compose.ymltocontainer-registry.oracle.com/database/free:latest.
docker-compose --profile mysql updocker-compose --profile postgres upNo setup needed. Data is lost when you stop the application.
# Maven
./mvnw mn:run
# Gradle alternative
./gradlew runThe docker-compose.yml file handles everything automatically:
- Starts the database
- Waits for it to be ready
- Starts the application
- Connects them together
Note: The repository supports both Maven and Gradle for local development. The
Dockerfileuses Maven by default, but includes commented Gradle build steps you can enable if you prefer building the image with Gradle.
To stop:
docker-compose --profile oracle down # for Oracle
docker-compose --profile mysql down # for MySQL
docker-compose --profile postgres down # for PostgreSQLTo remove data volumes:
docker-compose --profile oracle down -v
docker-compose --profile mysql down -v
docker-compose --profile postgres down -v# Build
./mvnw package
# Run
java -jar target/micronaut-petclinic-*.jar
# Gradle alternative
./gradlew build
java -jar build/libs/micronaut-petclinic-*.jarIf you have GraalVM installed:
# Build native executable (Maven)
./mvnw package -Pnative
# Run
./target/micronaut-petclinic
# Gradle alternative
./gradlew nativeCompile
./build/native/nativeCompile/micronaut-petclinic- Click "FIND OWNERS" in the navigation
- Click "Add Owner" to register a new owner
- Fill in the form and submit
- Search owners by last name using the search form
- Find an owner
- Click "Add New Pet" on the owner's page
- Select pet type (dog, cat, bird, etc.) and enter details
- Submit the form
- Go to an owner's page
- Click "Add Visit" next to one of their pets
- Enter visit date and description
- Submit the form
Click "VETERINARIANS" in the navigation to see all vets and their specialties.
Use the language selector in the top-right corner to switch between:
- English (default)
- Spanish (Español)
- German (Deutsch)
src/main/java/
└── io/micronaut/samples/petclinic/
├── model/ # JPA entities (Owner, Pet, Visit, Vet)
├── repository/ # Data access interfaces
├── service/ # Business logic
├── dto/ # Form objects
├── controller/ #
└── system/ #
src/main/resources/
├── views/ # JTE templates
├── static/ # CSS and images
├── i18n/ # Message translations
└── application*.yml # Configuration files
application.yml- Main configuration (H2 default)application-oracle.yml- Oracle settingsapplication-mysql.yml- MySQL settingsapplication-postgres.yml- PostgreSQL settings
To use a specific database locally:
export MICRONAUT_ENVIRONMENTS=oracle # for Oracle
export MICRONAUT_ENVIRONMENTS=mysql # for MySQL
export MICRONAUT_ENVIRONMENTS=postgres # for PostgreSQL
# Maven
./mvnw mn:run
# Gradle alternative
./gradlew run- Micronaut 4.x - Framework
- Java 21 - Programming language
- Micronaut Data JPA - Database access
- JTE - HTML template engine
- Hibernate - JPA implementation
- Caffeine - Caching
- Bootstrap 5 - CSS framework
# Run all tests (Maven)
./mvnw test
# Run integration tests (Maven)
./mvnw verify
# Gradle alternatives
./gradlew test
./gradlew test jacocoTestReport
./gradlew checkMain differences you'll encounter:
- Dependency Injection: Use constructor injection, not
@Autowired - Form Binding: Add
@Bodyannotation to form parameters in controllers - MessageSource: Must configure manually (not auto-configured)
- Templates: Use OGNL expressions instead of SpEL
- Configuration: Use YAML format, different property names
See migration-guide.md for detailed comparisons and examples.
Make sure the database is running before starting the app. With docker-compose, this is handled automatically. If running manually:
# Start database first
docker-compose --profile oracle up -d oracle
docker-compose --profile mysql up -d mysql
docker-compose --profile postgres up -d postgres
# Wait for database to be ready (longer for Oracle, 10s for MySQL/PostgreSQL)
export MICRONAUT_ENVIRONMENTS=oracle # or mysql, postgres
# Maven
./mvnw mn:run
# Gradle alternative
./gradlew runImage architecture mismatch: The default Oracle image is for ARM64 (Apple Silicon). For x86/AMD64:
# In docker-compose.yml, change:
image: container-registry.oracle.com/database/free:latestOracle takes long to start: Oracle Free needs 2-3 minutes on first startup. The healthcheck waits for it automatically.
# Find what's using the port
lsof -i :8080
# Kill it or use a different port
export MICRONAUT_SERVER_PORT=8081
# Maven
./mvnw mn:run
# Gradle alternative
./gradlew runCheck your application-{database}.yml file has the correct:
- URL
- Username
- Password