https://github.com/mzivkovicdev/spring-crud-generator
Generate production-ready Spring Boot backend boilerplate from a single YAML or JSON spec.
https://github.com/mzivkovicdev/spring-crud-generator
api apis crud crud-generator docker generator graphql graphql-codegen graphql-java java maven-plugin nosql rest rest-api spring spring-boot springboot springboot3 springboot4 sql
Last synced: 6 days ago
JSON representation
Generate production-ready Spring Boot backend boilerplate from a single YAML or JSON spec.
- Host: GitHub
- URL: https://github.com/mzivkovicdev/spring-crud-generator
- Owner: mzivkovicdev
- License: apache-2.0
- Created: 2025-07-28T12:06:11.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2026-04-07T13:53:45.000Z (18 days ago)
- Last Synced: 2026-04-07T14:48:02.821Z (18 days ago)
- Topics: api, apis, crud, crud-generator, docker, generator, graphql, graphql-codegen, graphql-java, java, maven-plugin, nosql, rest, rest-api, spring, spring-boot, springboot, springboot3, springboot4, sql
- Language: Java
- Homepage: https://markozivkovic.dev/
- Size: 2.17 MB
- Stars: 30
- Watchers: 0
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: Readme.MD
- Contributing: docs/contributing.md
- License: LICENSE.txt
- Security: SECURITY.md
- Notice: NOTICE
Awesome Lists containing this project
- fucking-awesome-java - Spring CRUD Generator - Maven plugin for generating Spring Boot CRUD applications from YAML/JSON specifications. (Projects / Code Generators)
- awesome-java - Spring CRUD Generator - Maven plugin for generating Spring Boot CRUD applications from YAML/JSON specifications. (Projects / Code Generators)
README
# Spring CRUD Generator
[](https://github.com/mzivkovicdev/spring-crud-generator/actions/workflows/ci.yml)
[](https://opensource.org/licenses/Apache-2.0)

[](https://central.sonatype.com/artifact/dev.markozivkovic/spring-crud-generator)
[](./docs/README.md)










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](https://www.youtube.com/watch?v=jwVINP_YxSk)
## 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](https://github.com/mzivkovicdev/spring-crud-generator-demo)
## Documentation
Full documentation is available in [`/docs`](./docs/README.md).
- [Getting started](./docs/getting-started.md)
- [Configuration reference](./docs/configuration.md)
- [Packages configuration](./docs/packages.md)
- [Entities and fields](./docs/entities.md)
- [Migrations](./docs/migrations.md)
- [Incremental generation](./docs/incremental-generation.md)
- [Spring CRUD Generator vs Bootify](./docs/comparison-with-bootify.md)
- [Full SQL spec example](./docs/examples/crud-spec-full.yaml)
- [Full MongoDB spec example](./docs/examples/mongo-crud-spec-full.yaml)
- [JSON Schema](./docs/schema/crud-spec.schema.json)
> 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
### 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:
- New user? → [Getting started](./docs/getting-started.md)
- Need all available options? → [Configuration reference](./docs/configuration.md)
- Working with entities and fields? → [Entities and fields](./docs/entities.md)
- Need package customization? → [Packages configuration](./docs/packages.md)
- Need a complete SQL example? → [Full SQL spec example](./docs/examples/crud-spec-full.yaml)
- Need a complete MongoDB example? → [Full MongoDB spec example](./docs/examples/mongo-crud-spec-full.yaml)
- Want autocomplete/validation? → [JSON Schema](./docs/schema/crud-spec.schema.json)
---
## 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`:
```xml
generate-resources
dev.markozivkovic
spring-crud-generator
1.8.0
generate-spring-crud
generate
${project.basedir}/src/main/resources/crud-spec.yaml
${project.basedir}/src/main/java/com/sql/demo/springboot_postgres_json_demo
true
```
### 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`.
```text
src/main/resources/crud-spec.yaml
```
**SQL example (PostgreSQL, MySQL, MariaDB, MSSQL)**
```yaml
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**
```yaml
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
# yaml-language-server: $schema=https://raw.githubusercontent.com/mzivkovicdev/spring-crud-generator/main/docs/schema/crud-spec.schema.json
configuration:
database: postgresql
```
JSON (`*.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:
```bash
mvn spring-crud-generator:validate -DinputSpecFile=src/main/resources/crud-spec.yaml
```
### Step 4: Run the generator
Run the generator using the Maven profile:
```bash
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)
- 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: `generator-state.json` and `migration-state.json`
- Setting `forceRegeneration=true` ignores these files
- Database tables are never dropped automatically
---
## Supported Java versions
- Java **17** – **25**
---
## License
This project is licensed under the Apache License 2.0 - see the [LICENSE](./LICENSE.txt) file for details.
---
## Contact
For questions, feedback, collaboration, or support, feel free to reach out::
- Email: **mzivkovic.dev@gmail.com**
- LinkedIn: [Marko Zivkovic](https://www.linkedin.com/in/marko-zivkovic-84547017a/)