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.
Watch the demo on YouTube: Spring CRUD Generator Demo
- Starting new Spring Boot backends faster
- Teams that want a consistent backend baseline
- Developers who want inspectable generated code, not a black box
See the demo project generated from a real spec: Spring Crud Demo
Full documentation is available in /docs.
- Getting started
- Configuration reference
- Packages configuration
- Entities and fields
- Migrations
- Incremental generation
- Spring CRUD Generator vs Bootify
- Full SQL spec example
- Full MongoDB spec example
- JSON Schema
Maven Central:
dev.markozivkovic:spring-crud-generator:1.8.0
Artifact page: https://central.sonatype.com/artifact/dev.markozivkovic/spring-crud-generator
- Entities / Documents
- Repositories
- Services
- DTOs and mappers
- REST controllers
- Database migrations (Flyway for SQL, Mongock for MongoDB)
- OpenAPI resources
- GraphQL
- Docker resources
- Caching
- Optimistic locking
- Unit tests
- JSON Schema validation
- Incremental generation
⚠️ Table/collection deletion is not supported by the generator and must be handled manually.
Choose what you need:
- New user? → Getting started
- Need all available options? → Configuration reference
- Working with entities and fields? → Entities and fields
- Need package customization? → Packages configuration
- Need a complete SQL example? → Full SQL spec example
- Need a complete MongoDB example? → Full MongoDB spec example
- Want autocomplete/validation? → JSON Schema
Generate a fully functional Spring Boot CRUD application in minutes using a single YAML or JSON configuration file.
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>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: 255MongoDB 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: 255This 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.
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: postgresqlJSON (*.json):
{
"$schema": "https://raw.githubusercontent.com/mzivkovicdev/spring-crud-generator/main/docs/schema/crud-spec.schema.json",
"configuration": {
"database": "postgresql"
}
}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.yamlRun the generator using the Maven profile:
mvn clean install -Pgenerate-resourcesAfter execution:
- source code is generated into the directory defined by
outputDir - Flyway migration scripts are generated (if enabled, SQL databases)
- Mongock
@ChangeUnitclasses are generated (if enabled, MongoDB) - Swagger/OpenAPI resources are generated (if enabled)
- Docker and Docker Compose files are generated (if enabled)
| 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.
Incremental generation is enabled by default:
- Generator state is stored in:
generator-state.jsonandmigration-state.json - Setting
forceRegeneration=trueignores these files - Database tables are never dropped automatically
- Java 17 – 25
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
For questions, feedback, collaboration, or support, feel free to reach out::
- Email: mzivkovic.dev@gmail.com
- LinkedIn: Marko Zivkovic