Troubleshooting
Reading Sprout’s compile-time output
Section titled “Reading Sprout’s compile-time output”Sprout emits compiler notes prefixed with [Sprout]. During a Maven build you will see lines
like:
[Sprout] Processing: com.example.domain.Book[Sprout] Resolved ID: field 'id' (type: java.lang.Long)[Sprout] Base API path: /api/booksWarnings about missing optional dependencies also use this prefix, so check the full build output if something is missing.
“Nothing is generated”
Section titled ““Nothing is generated””Symptoms: No Sprout* files appear in the build output.
Checklist:
-
Annotation processing is disabled in your IDE or build.
- Maven: verify
sprout-processoris in<annotationProcessorPaths>insidemaven-compiler-plugin, not in<dependencies>. - Gradle: verify it uses the
annotationProcessorconfiguration, notimplementation. - IDE: enable annotation processing (see Installation).
- Maven: verify
-
The entity is not annotated.
@SproutResourcehasRetentionPolicy.SOURCE; it is absent from bytecode, so runtime reflection cannot find it. Sprout only sees it at compile time. Confirm the annotation is on the entity class. -
A compilation error earlier in the build aborted processing. Sprout only runs when the source files it annotates compile without errors.
“Generated controllers are not picked up by Spring”
Section titled ““Generated controllers are not picked up by Spring””Symptoms: App starts but endpoints return 404.
Generated controllers live in {entity-package}.generated.controllers. Spring’s component
scan must include this package.
- If your
@SpringBootApplicationis in a parent package of the entity package, the scan covers it automatically. - If your application class is in a different root package, add an explicit scan:
@SpringBootApplication@ComponentScan({ "com.example.app", "com.example.domain" })public class MyApplication { ... }“Swagger/OpenAPI tags and responses are missing”
Section titled ““Swagger/OpenAPI tags and responses are missing””Symptoms: Sprout generated controllers, but they have no @Tag or @ApiResponses.
- Ensure
@SproutResource(generateSwaggerDocs = true)(this is the default; check that it hasn’t been set tofalse). - Ensure SpringDoc OpenAPI types are on the compile classpath at the time Sprout runs.
If they are present only at runtime (
runtimeOnly/runtimescope) Sprout cannot see them and will skip annotation generation.
“@SproutPolicy has no effect (endpoints not protected)”
Section titled ““@SproutPolicy has no effect (endpoints not protected)””@PreAuthorize is generated but has no runtime effect without method security enabled.
- Add
@EnableMethodSecurityto a@Configurationclass, or - Set
sprout.security.method-security.enabled=trueviasprout-runtime. - Also confirm Spring Security is on the classpath and you have a
SecurityFilterChainbean configured.
“Compilation error: multiple IDs / no ID found”
Section titled ““Compilation error: multiple IDs / no ID found””Sprout requires exactly one identifier field or getter per entity.
- No ID found: add
@jakarta.persistence.Idto the primary key field, or use@SproutIdon a different field. - Multiple IDs found: ensure only one field/getter carries one of:
@SproutId,@jakarta.persistence.Id,@javax.persistence.Id. - Using
@EmbeddedId: this is not supported. See Limitations.
“Compilation error: invalid SpEL in @SproutPolicy”
Section titled ““Compilation error: invalid SpEL in @SproutPolicy””Sprout validates all SpEL expressions at compile time. A syntax error in any @SproutPolicy
string fails the build with a message pointing to the offending annotation. Fix the
expression and recompile.
“Project doesn’t compile after enabling authenticationPrincipal = true”
Section titled ““Project doesn’t compile after enabling authenticationPrincipal = true””authenticationPrincipal = true causes Sprout to add Authentication authentication
parameters to generated controller methods. This type comes from
spring-boot-starter-security. If Spring Security is not on your compile classpath, the
generated files reference an unknown type and compilation fails.
- Add
spring-boot-starter-securityas a dependency, or - Remove
authenticationPrincipal = true(default isfalse).