{"record":{"id":"74b5f63430f1968c","repo":"quarkusio/quarkus","slug":"component-class-is-annotated-with-multiple-confl","errorCode":null,"errorMessage":"Component <class> is annotated with multiple conflicting names: <names>","messagePattern":"Component <class> is annotated with multiple conflicting names: <names>","errorType":"exception","errorClass":"DefinitionException","httpStatus":null,"severity":"error","filePath":"extensions/spring-di/deployment/src/main/java/io/quarkus/spring/di/deployment/SpringDIProcessor.java","lineNumber":661,"sourceCode":"        }\n    }\n\n    /**\n     * Get the name of a bean or throw a {@link DefinitionException} if it has more than one name\n     *\n     * @param clazz The class annotated with the names\n     * @param names The names\n     * @return The bane name\n     */\n    private String validateName(final ClassInfo clazz, final Set<String> names) {\n        final int size = names.size();\n        switch (size) {\n            case 0:\n                return null;\n            case 1:\n                return names.iterator().next();\n            default:\n                throw new DefinitionException(\n                        \"Component \" + clazz.name() + \" is annotated with multiple conflicting names: \"\n                                + String.join(\", \", names));\n        }\n    }\n}\n","sourceCodeStart":643,"sourceCodeEnd":667,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/spring-di/deployment/src/main/java/io/quarkus/spring/di/deployment/SpringDIProcessor.java#L643-L667","documentation":"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.","triggerScenarios":"A class annotated with two or more annotations that each supply a distinct bean name, with no single unambiguous name.","commonSituations":"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.","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"],"exampleFix":"// before\n@Component(\"userService\")\n@MyNamedStereotype(\"userBean\")\nclass UserService {}\n\n// after\n@Component(\"userService\")\n@MyNamedStereotype\nclass UserService {}","handlingStrategy":"validation","validationCode":"List<String> names = collectNameBearingAnnotationValues(clazz);\nif (names.size() > 1) {\n    throw new IllegalStateException(\"Multiple bean names on \" + clazz.getName() + \": \" + names);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Give only one annotation per component a name value","Use @Bean methods for beans needing several names","Audit custom stereotype annotations for name attributes"],"tags":["spring-di","bean-name","cdi","quarkus"],"backgroundTag":"ambiguous-bean-name","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}