Spring Hex CLI

Generate hexagonal architecture scaffolding for Spring Boot projects in seconds.

Get Started Command Reference


Spring Hex CLI is a command-line tool that generates hexagonal architecture (ports and adapters), CQRS, and DDD scaffolding code for Spring Boot projects. It eliminates the boilerplate of setting up clean architecture, letting you focus on domain logic.

Quick Example

# Initialize configuration
spring-hex init

# Set up CQRS infrastructure (CommandBus, QueryBus, etc.)
spring-hex make:mediator

# Generate a full bounded context for "Order"
spring-hex make:module Order

This generates a complete module with:

  • Domain model, aggregate root, value objects
  • CQRS commands, queries, and handlers
  • Repository port and JPA adapter
  • REST controller
  • Event infrastructure
  • Mapper between domain and persistence layers

Features

Hexagonal Architecture — Generates domain, port, and adapter layers with proper dependency inversion.

CQRS Support — Built-in CommandBus/QueryBus pattern with auto-wired handlers.

Multiple Data Stores — JPA, MongoDB, and Redis adapter generation out of the box.

Database Migrations — Flyway and Liquibase support with auto-detection.

Customizable Paths — Configure package structure via .hex/config.yml to match your conventions.

Simple CRUD Toomake:crud generates a full MVC stack when you don’t need hexagonal complexity.

Data Seeding — Generate factories with Datafaker and seeders for populating dev/test databases.

What It Generates

Layer Components
Domain Models, Aggregates, Value Objects, Commands, Queries, Events, Ports
Infrastructure Controllers, Repository Adapters, Event Listeners, Mappers, JPA Entities
Mediator CommandBus, QueryBus, Handler interfaces, Configuration
Data Seeding Factories (Datafaker), Seeders, SeedRunner
Migration Flyway SQL, Liquibase XML/YAML/SQL changesets
Tests Feature tests (SpringBootTest), Unit tests (Mockito)

Ready to get started? Head to the Installation Guide.


Back to top

Spring Hex CLI — Hexagonal Architecture scaffolding for Spring Boot

This site uses Just the Docs, a documentation theme for Jekyll.