DEV Community

Marko
Marko

Posted on

Spring CRUD Generator: a YAML/JSON-driven Spring Boot backend generator (version update + stability improvements)

If you saw my initial post about Spring CRUD Generator v1.0.0, this is a follow-up with a version update and a more complete overview of what the project is aiming to solve.

Spring CRUD Generator is an open-source Maven plugin that generates a Spring Boot backend from a single YAML/JSON spec. The main goal is to reduce repetitive CRUD boilerplate and keep a consistent baseline across projects.

Version update: 1.0.2

Why I built this

In most Spring Boot projects, the first few hours (or days) often look the same:

  • CRUD layers (entity/repo/service/controller)
  • DTO mapping / mappers
  • consistent error responses
  • database migrations (and keeping them in sync)
  • Docker bits
  • OpenAPI and resource structures
  • tests and test data setup

Spring CRUD Generator tries to make that “baseline” reproducible from a spec, so you can focus on domain logic instead of wasting your time and concentration writing the same code again and again.

What it can generate

Depending on the configuration, it can generate:

  • CRUD stack: entities, repositories, services, mappers, REST controllers
  • Flyway migrations (incremental change detection)
  • OpenAPI specs + optional resource generation
  • Dockerfile + docker-compose
  • Unit tests + test data generation (Instancio/Podam)
  • Caching (Redis/Caffeine)
  • GraphQL

What improved since v1.0.0

The initial version proved the concept, but real usage quickly exposed edge cases. Recent releases focus on stability and correctness, especially around:

  • OpenAPI generation and schema handling (including optional fields)
  • ID naming consistency across endpoints and DTOs
  • improved equals/hashCode generation depending on whether the model is JSON-centric or a table entity
  • stricter validation so misconfigurations fail fast

Example spec (YAML)

Here is a small example showing the overall idea:

configuration:
  database: postgresql
  migrationScripts: true
  errorResponse: MINIMAL
  openApi:
    apiSpec: true
    generateResources: true
  docker:
    dockerfile: true
    dockerCompose: true
  tests:
    unit: true
    dataGenerator: instancio

entities:
  - name: Product
    storageName: product_table
    audit:
      enabled: true
      type: LocalDate
    fields:
      - name: id
        type: Long
        id:
          strategy: IDENTITY
      - name: name
        type: String
      - name: tags
        type: List<String>
Enter fullscreen mode Exit fullscreen mode

Quick start

  • Create your spec file, for example:
src/main/resources/crud-generator.yml
Enter fullscreen mode Exit fullscreen mode
  • Configure the Maven plugin (see the repository README)
  • Run generation
mvn clean install -DskipTests -Pgenerate-resources
Enter fullscreen mode Exit fullscreen mode

This should generate the backend sources and related resources based on your YAML/JSON spec.

Links

  • Github repo:
https://github.com/mzivkovicdev/spring-crud-generator
Enter fullscreen mode Exit fullscreen mode
  • Maven Central artifact:
dev.markozivkovic:spring-crud-generator:1.0.2
Enter fullscreen mode Exit fullscreen mode

Feedback welcome

If you have a few minutes, I’d love feedback on:

  • the spec design (YAML/JSON structure and ergonomics)
  • what you expect from generated “production baseline” code
  • edge cases you’d test first

Top comments (0)