quarkusio/quarkus · error · DefinitionException
Component <class> is annotated with multiple conflicting nam
Error message
Component <class> is annotated with multiple conflicting names: <names>
What it means
A Spring component resolves to more than one bean name, e.g. through multiple name-carrying annotations (custom composed annotations whose meta-annotations declare distinct name values). The processor cannot pick a single bean name and throws a DefinitionException at build time.
Source
Thrown at extensions/spring-di/deployment/src/main/java/io/quarkus/spring/di/deployment/SpringDIProcessor.java:661
}
}
/**
* Get the name of a bean or throw a {@link DefinitionException} if it has more than one name
*
* @param clazz The class annotated with the names
* @param names The names
* @return The bane name
*/
private String validateName(final ClassInfo clazz, final Set<String> names) {
final int size = names.size();
switch (size) {
case 0:
return null;
case 1:
return names.iterator().next();
default:
throw new DefinitionException(
"Component " + clazz.name() + " is annotated with multiple conflicting names: "
+ String.join(", ", names));
}
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Remove all but one name-bearing annotation, keeping the intended bean name
- Set the desired name explicitly on a single annotation (e.g. @Component("myName")) and strip the name from the stereotype
- If multiple names are genuinely needed, register additional beans via @Bean methods in a configuration class
Example fix
// before
@Component("userService")
@MyNamedStereotype("userBean")
class UserService {}
// after
@Component("userService")
@MyNamedStereotype
class UserService {} Defensive patterns
Strategy: validation
Validate before calling
List<String> names = collectNameBearingAnnotationValues(clazz);
if (names.size() > 1) {
throw new IllegalStateException("Multiple bean names on " + clazz.getName() + ": " + names);
} Prevention
- Give only one annotation per component a name value
- Use @Bean methods for beans needing several names
- Audit custom stereotype annotations for name attributes
When it happens
Trigger: A class annotated with two or more annotations that each supply a distinct bean name, with no single unambiguous name.
Common situations: Migrating Spring apps using custom stereotype annotations that set bean names; stacking @Component("a") with another name-bearing annotation; refactoring that left duplicate name annotations in place.
Related errors
- AnnotationInstance ${instance} is an invalid target. Only Cl
- AnnotationInstance <annotationInstance> is an invalid target
- Components annotated with multiple conflicting scopes must d
- Multiple @Inject constructors on ${theClass}
- Quarkus does not support CDI Full @Specializes annotation; t
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/74b5f63430f1968c.
Report an issue: GitHub.