Introduction
Sprout is a compile-time annotation processor that generates Spring Boot REST scaffolding from your JPA entities. Annotate an entity, compile, and Sprout writes the REST layer into your build output. You ship less boilerplate; Spring picks it up automatically.
What Sprout generates
Section titled “What Sprout generates”For every entity annotated with @SproutResource, Sprout produces five Java source files:
| Generated type | What it is |
|---|---|
Sprout{Name}Controller |
@RestController exposing CRUD endpoints |
Sprout{Name}Operations |
Interface the controller depends on (your override point) |
Sprout{Name}Service |
Default implementation of the operations interface |
Sprout{Name}Repository |
JpaRepository subinterface with a custom JPQL deleteById |
Sprout{Name}Marker |
Class with public static final constants (path, ID type, entity name, policies) |
Generated sources land in the entity’s package under a .generated subpackage, so Spring’s
component scan picks them up automatically as long as your @SpringBootApplication covers the
entity package.
The three modules
Section titled “The three modules”Sprout is published as three separate artifacts so you only pull in what you need:
sprout-annotations
Section titled “sprout-annotations”Contains the public API:
@SproutResource— marks an entity for generation and controls what is generated.@SproutPolicy— attaches SpEL-based security expressions per HTTP operation.@SproutId— overrides which field or getter Sprout treats as the entity identifier.Endpoint— enum used withinclude/excludeto select individual endpoints.
These annotations have RetentionPolicy.SOURCE; they exist only at compile time and are not
present in the compiled bytecode.
Add this as a regular compile/implementation dependency.
sprout-processor
Section titled “sprout-processor”The javax.annotation.processing.Processor implementation. Registered automatically via Google
AutoService so no META-INF/services wiring is needed on your end.
Configure this as an annotation processor in your build tool — not a normal dependency. See Installation for the exact Maven and Gradle snippets.
sprout-runtime (optional)
Section titled “sprout-runtime (optional)”Provides Spring Boot auto-configuration for two optional features:
- Unified error responses — a
@RestControllerAdvicethat converts common exceptions (validation failures, 404s, internal errors) into a consistent JSON structure. - Method-security auto-configuration — enables
@EnableMethodSecurityvia a property so@SproutPolicypolicies are enforced without any manual setup.
Add this only if you want these runtime features; Sprout works without it.