Redundant Qualifier On Bean Method

ID

java.spring_qualifier_on_bean_method

Severity

low

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Code Smell

Language

Java

Tags

best-practice, code-style, spring

Description

Reports @Qualifier on a method that is also annotated @Bean.

Rationale

A @Bean method already names its bean, either explicitly through @Bean(name = …​) or implicitly from the method name. Adding @Qualifier to the same method does not change how the bean is registered or resolved — it only duplicates a name that is already available, and invites a reader to wonder which of the two is authoritative. The bean works identically with or without it, so this is redundancy rather than a defect.

@Qualifier on one of the method’s parameters is a different, legitimate use: it disambiguates which bean should be injected at that parameter, and is not reported by this rule.

// Redundant - the bean is already named "reportingService"
@Bean
@Qualifier("reportingService")
public ReportingService reportingService() {
  return new DefaultReportingService();
}

Remediation

Drop @Qualifier and rely on the bean’s own name.

// Good - name comes from the method (or @Bean(name = ...))
@Bean
public ReportingService reportingService() {
  return new DefaultReportingService();
}

© 2026 Xygeni. All rights reserved