
Spring Boot Dependency Injection
Constructor injection is the right default for Spring, but a lot of legacy code still leans on field injection and nullable optionals. This skill walks you through separating mandatory from optional collaborators, using ObjectProvider for conditional features, and applying @Primary and @Qualifier only when you actually need them. The wiring validation section is solid: start with a minimal context test to catch bean problems before you write business logic. The no-op fallback pattern for optional dependencies is cleaner than sprinkling null checks everywhere. If you're refactoring services or onboarding someone who keeps reaching for @Autowired on fields, this gives you a concrete playbook.
- skills.sh installs
- 3.9K
- GitHub stars
- 369
- last updated
- Aug 21, 2026
Install
$ npx -y skills add giuseppe-trisciuoglio/developer-kit --skill spring-boot-dependency-injection --agent claude-codeInstalls into .claude/skills of the current project.
Files
Spring Boot Dependency Injection
Overview
Provides constructor-first dependency injection patterns for Spring Boot:
- mandatory collaborators via constructor injection
- optional collaborators via
ObjectProvideror no-op fallbacks - bean selection via
@Primaryand@Qualifier - validation via minimal context tests before full integration
When to Use
Use this skill when:
- creating a new
@Service,@Component,@Repository, or@Configurationclass - replacing field injection in legacy Spring code
- resolving multiple beans of the same type with qualifiers or primary beans
- handling optional features, adapters, or integrations without null-driven wiring
- reviewing circular dependencies or brittle context startup failures
- preparing code for direct constructor-based unit testing
Instructions
1. Separate mandatory and optional collaborators
For each class, identify:
- mandatory collaborators required for correct behavior
- optional collaborators that enable integrations, caching, notifications, or feature-flagged behavior
Sponsors
Details
- Repository
- github.com/giuseppe-trisciuoglio/developer-kit
- Categories
- Debugging, Java & JVM, Design & UI/UX
- First seen
- May 16, 2026
More from giuseppe-trisciuoglio/developer-kit
All 102- Unit Test Controller Layer3.9K
- Unit Test Parameterized3.9K
- Unit Test Json Serialization3.9K
- Spring Boot Saga Pattern3.9K
- Spring Data Neo4j3.9K
- Unit Test Security Authorization3.9K
- Nextjs Data Fetching3.9K
- Langchain4j Tool Function Calling Patterns3.9K
- Nx Monorepo3.9K
- Langchain4j Spring Boot Integration3.9K
- Langchain4j Rag Implementation Patterns3.9K
- Unit Test Scheduled Async3.9K
- Rag3.9K
- Unit Test Utility Methods3.9K
- Qdrant3.9K
- Unit Test Exception Handler3.9K
- Unit Test Mapper Converter3.9K
- Langchain4j Ai Services Patterns3.9K
- Unit Test Caching3.8K
- Unit Test Config Properties3.8K
- Unit Test Application Events3.8K
- Langchain4j Vector Stores Configuration3.8K
- Langchain4j Mcp Server Patterns3.8K
- Aws Sdk Java V2 S33.8K