Dependency injection workflow for Spring Boot projects covering constructor-first patterns, optional collaborator handling, bean selection, and validation practices.
/plugin marketplace add giuseppe-trisciuoglio/developer-kit/plugin install developer-kit@giuseppe.trisciuoglioThis skill is limited to using the following tools:
references/examples.mdreferences/reference.mdreferences/spring-official-dependency-injection.mdThis skill captures the dependency injection approach promoted in this repository: constructor-first design, explicit optional collaborators, and deterministic configuration that keeps services testable and framework-agnostic.
@Service, @Component, or @Repository classes.@ServiceConnection../gradlew test or mvn test for validation../references/ when deeper patterns or samples are required.@Autowired members, and configuration classes.@RequiredArgsConstructor) that accept every mandatory collaborator.final and protect invariants with Objects.requireNonNull if Lombok is not used.@Configuration or @Bean factories to pass dependencies explicitly; consult ./references/reference.md for canonical bean wiring.@Autowired(required = false) or inject ObjectProvider<T> for lazy access../references/examples.md#example-2-setter-injection-for-optional-dependencies for a full workflow.@Primary for dominant implementations and @Qualifier for niche variants../references/reference.md#conditional-bean-registration for conditional and profile-based samples.@WebMvcTest, @DataJpaTest, @SpringBootTest) only after constructor contracts are validated../references/reference.md#testing-with-dependency-injection to select the proper test style.@Service
@RequiredArgsConstructor
public class UserService {
private final UserRepository userRepository;
private final EmailService emailService;
public User register(UserRegistrationRequest request) {
User user = User.create(request.email(), request.name());
userRepository.save(user);
emailService.sendWelcome(user);
return user;
}
}
new UserService(mockRepo, mockEmailService); with no Spring context required.@Service
public class ReportService {
private final ReportRepository reportRepository;
private CacheService cacheService = CacheService.noOp();
public ReportService(ReportRepository reportRepository) {
this.reportRepository = reportRepository;
}
@Autowired(required = false)
public void setCacheService(CacheService cacheService) {
this.cacheService = cacheService;
}
}
CacheService.noOp() to ensure deterministic behavior when the optional bean is absent.@Configuration
@Import(DatabaseConfig.class)
public class MessagingConfig {
@Bean
@ConditionalOnProperty(name = "feature.notifications.enabled", havingValue = "true")
public NotificationService emailNotificationService(JavaMailSender sender) {
return new EmailNotificationService(sender);
}
@Bean
@ConditionalOnMissingBean(NotificationService.class)
public NotificationService noopNotificationService() {
return NotificationService.noOp();
}
}
@Import, profiles, and conditional annotations to orchestrate cross-cutting modules.Additional worked examples (including tests and configuration wiring) are available in ./references/examples.md.
@Autowired on single constructors.null pointers.@Lazy usage to performance-sensitive paths and record the deferred initialization risk.spring-boot-crud-patterns – service-layer orchestration patterns that rely on constructor injection.spring-boot-rest-api-standards – controller-layer practices that assume explicit dependency wiring.unit-test-service-layer – Mockito-based testing patterns for constructor-injected services.This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.