Spring Bean Injection Not Enrolled Student
Symptom
Application startup fails with BeanCreationException or an autowiring error around NotEnrolledStudentRepository or a closely related service.
The original April 5, 2026 incident record is incomplete: it preserved only a screenshot, not the full stack trace or the follow-up fix commit.
What Is Confirmed
- the failure happened at Spring context refresh time, not during a later request;
NotEnrolledStudentRepositorywas part of the missing dependency chain in the screenshot;- the incident happened before the current backend monolith structure settled.
The current repo no longer contains NotEnrolledStudentRepository, so this page documents the failure pattern and diagnostic path rather than a live module contract.
Likely Causes
- missing
@Repository,@Component, or Spring Data interface inheritance on a newly added repository; - package placement outside the application's component scan or repository scan;
- a circular dependency introduced while wiring a new domain service;
- multiple bean candidates with no
@Qualifieror@Primary.
Diagnosis
When this class of failure appears, check in this order:
- Does the repository interface extend the expected Spring Data base interface or carry the right stereotype annotation?
- Is the package inside the active
@SpringBootApplicationand@EnableJpaRepositoriesscan path? - Does the stack trace show a dependency cycle rather than a simple missing bean?
- Are there multiple beans of the same type competing for injection?
Because the historical record is incomplete, do not assume the root cause was annotation drift. Reconstruct the exact bean-creation chain from logs before changing code.
Fix
- add the missing stereotype or repository inheritance;
- move or rescan the package;
- break circular dependencies by restoring one-way layer boundaries;
- resolve bean ambiguity with
@Qualifieror@Primaryonly when multiple beans are genuinely intentional.
Prevention
- Keep full stack traces, not just screenshots, for Spring boot failures.
- Add a context-load test for any module that introduces a new repository or service graph.
- Treat startup-time bean failures as fast feedback: they are cheaper to fix than partially working runtime wiring.
Source Incident Detail
The April 5, 2026 source record is intentionally cautious: the exact stack trace was not preserved, so the root cause cannot be stated as fact. The useful retained value is the diagnostic shape for a missing NotEnrolledStudentRepository bean.
| Detail | Value |
|---|---|
| Affected area | Spring bean creation for a repository/service graph |
| Evidence quality | partial; likely screenshot-based |
| Confirmed symptom | startup-time missing bean or injection failure |
| Not confirmed | exact annotation, scan path, or circular-dependency root cause |
| Durable lesson | keep complete stack traces for Spring boot failures |
When reconstructing a similar failure, separate these cases before editing code:
| Case | Evidence |
|---|---|
| missing repository stereotype or inheritance | repository interface is not a Spring Data repository bean |
| package scan miss | repository package is outside application/repository scan boundaries |
| circular dependency | stack trace shows a dependency cycle rather than a missing candidate |
| bean ambiguity | multiple candidates exist but injection lacks a qualifier |
Do not treat this historical page as proof that the original fix was annotation-only. It is a runbook for reconstructing the evidence correctly next time.