Home
Softono

Spring Crud Generator

Open source Apache-2.0 Java
35
Stars
2
Forks
3
Issues
0
Watchers
3 months
Last Commit

 About Spring Crud Generator

Generate production-ready Spring Boot backend boilerplate from a single YAML or JSON spec.

Platforms

Web Self-hosted Docker

Languages

Java

Need Help Installing Spring Crud Generator?

We provide expert installation service for this software. Our team will install, configure, and secure Spring Crud Generator on your server. plans start at just $30.

Spring Crud Generator

View on GitHub

Spring CRUD Generator

CI License Open Source Maven Central Docs

Java Spring Boot 3 Spring Boot 4

PostgreSQL MySQL MariaDB Microsoft SQL Server MongoDB Redis Hazelcast

Generate production-ready Spring Boot backend boilerplate from a single YAML or JSON spec.

A Maven plugin for bootstrapping consistent, inspectable Spring Boot backends with generated CRUD layers, migrations, API docs, tests, and more.

Demo video

Watch the demo on YouTube: Spring CRUD Generator Demo

Best for

  • Starting new Spring Boot backends faster
  • Teams that want a consistent backend baseline
  • Developers who want inspectable generated code, not a black box

Try a full generated example

See the demo project generated from a real spec: Spring Crud Demo

Documentation

Full documentation is available in /docs.

Maven Central: dev.markozivkovic:spring-crud-generator:1.8.0
Artifact page: https://central.sonatype.com/artifact/dev.markozivkovic/spring-crud-generator


What you get

Core backend

  • Entities / Documents
  • Repositories
  • Services
  • DTOs and mappers
  • REST controllers

Optional platform features

  • Database migrations (Flyway for SQL, Mongock for MongoDB)
  • OpenAPI resources
  • GraphQL
  • Docker resources
  • Caching
  • Optimistic locking
  • Security (Basic Auth, JWT, OAuth2 Resource Server, API Key)
  • AI context files (CLAUDE.md, AGENTS.md)

Developer experience

  • Unit tests
  • JSON Schema validation
  • Incremental generation

⚠️ Table/collection deletion is not supported by the generator and must be handled manually.


Documentation guide

Choose what you need:


Quick start

Generate a fully functional Spring Boot CRUD application in minutes using a single YAML or JSON configuration file.

Step 1: Add Maven Profile

Add the following profile section to your pom.xml:

<profiles>
    <profile>
        <id>generate-resources</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>dev.markozivkovic</groupId>
                    <artifactId>spring-crud-generator</artifactId>
                    <version>1.8.0</version>
                    <executions>
                        <execution>
                            <id>generate-spring-crud</id>
                            <goals>
                                <goal>generate</goal>
                            </goals>
                            <configuration>
                                <inputSpecFile>
                                    ${project.basedir}/src/main/resources/crud-spec.yaml
                                </inputSpecFile>
                                <outputDir>
                                    ${project.basedir}/src/main/java/com/sql/demo/springboot_postgres_json_demo
                                </outputDir>
                                <forceRegeneration>true</forceRegeneration>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

Step 2: Create configuration file

Create the configuration file at the location defined by inputSpecFile. The file name is arbitrary. Only the extension matters: .yaml, .yml, or .json.

src/main/resources/crud-spec.yaml

SQL example (PostgreSQL, MySQL, MariaDB, MSSQL)

configuration:
  database: postgresql
  openApi:
    apiSpec: true
    generateResources: true
  errorResponse: simple
  tests:
    unit: true
    dataGenerator: instancio
entities:
  - name: ProductModel
    storageName: product_table
    description: "Represents a product"
    fields:
      - name: id
        type: Long
        description: "The unique identifier for the product"
        id:
          strategy: IDENTITY
      - name: name
        description: "The name of the product"
        type: String
        column:
          nullable: false
          unique: true
          length: 255

MongoDB example

configuration:
  database: mongodb
  openApi:
    apiSpec: true
    generateResources: true
  errorResponse: simple
  tests:
    unit: true
    dataGenerator: instancio
entities:
  - name: ProductModel
    storageName: products
    description: "Represents a product"
    fields:
      - name: id
        type: String
        id: true
        description: "MongoDB document id"
      - name: name
        description: "The name of the product"
        type: String
        validation:
          required: true
          notBlank: true
          maxLength: 255

This spec file can define:

  • global generator configuration (database, OpenAPI, Docker, tests, caching, migration scripts, etc.)
  • entities/documents, fields, constraints, and relationships
  • additional features like base path, soft delete, audit, and more

Note: the examples above show only a minimal subset. See the full examples for all available options.

Both YAML (.yaml/.yml) and JSON (.json) formats are supported.

Copilot + autocomplete for spec files

For better completion in VS Code/Copilot, bind your spec to the schema.

YAML (*.yaml / *.yml):

# yaml-language-server: $schema=https://raw.githubusercontent.com/mzivkovicdev/spring-crud-generator/main/docs/schema/crud-spec.schema.json
configuration:
  database: postgresql

JSON (*.json):

{
  "$schema": "https://raw.githubusercontent.com/mzivkovicdev/spring-crud-generator/main/docs/schema/crud-spec.schema.json",
  "configuration": {
    "database": "postgresql"
  }
}

Step 3: Validate spec (dry-run, optional)

Use the validate goal to check whether the spec file is valid before generating code:

mvn spring-crud-generator:validate -DinputSpecFile=src/main/resources/crud-spec.yaml

Step 4: Run the generator

Run the generator using the Maven profile:

mvn clean install -Pgenerate-resources

After execution:

  • source code is generated into the directory defined by outputDir
  • Flyway migration scripts are generated (if enabled, SQL databases)
  • Mongock @ChangeUnit classes are generated (if enabled, MongoDB)
  • Swagger/OpenAPI resources are generated (if enabled)
  • GraphQL resources are generated (if enabled)
  • Docker and Docker Compose files are generated (if enabled)

Step 5: Configuration parameters

Parameter Description
inputSpecFile Path to the YAML/JSON configuration file
outputDir Directory where generated source code is written
forceRegeneration Forces regeneration of all non-ignored entities, ignoring state files

For the validate goal, only inputSpecFile is required.

Important notes

Incremental generation is enabled by default:

  • Generator state is stored in: .crud-generator/generator-state.json
  • Migration state is stored in: .crud-generator/migration-state.json (SQL) or .crud-generator/mongock-state.json (MongoDB)
  • Setting forceRegeneration=true ignores these files
  • Database tables are never dropped automatically

Supported Java versions

  • Java 1725

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.


Contact

For questions, feedback, collaboration, or support, feel free to reach out::