{"id":"b40a867857ce1aa0","repo":"spring-projects/spring-framework","slug":"more-than-1-matching-bean","errorCode":null,"errorMessage":"more than 1 matching bean","messagePattern":"more than 1 matching bean","errorType":"exception","errorClass":"NoUniqueBeanDefinitionException","httpStatus":null,"severity":"error","filePath":"spring-beans/src/main/java/org/springframework/beans/factory/ObjectProvider.java","lineNumber":93,"sourceCode":"\t * but still excluding non-autowire candidates when used on injection points.\n\t * @since 6.2.3\n\t * @see #stream(Predicate)\n\t * @see #orderedStream(Predicate)\n\t * @see org.springframework.beans.factory.config.BeanDefinition#isAutowireCandidate()\n\t * @see org.springframework.beans.factory.support.AbstractBeanDefinition#isDefaultCandidate()\n\t */\n\tPredicate<Class<?>> UNFILTERED = (clazz -> true);\n\n\n\t@Override\n\tdefault T getObject() throws BeansException {\n\t\tIterator<T> it = iterator();\n\t\tif (!it.hasNext()) {\n\t\t\tthrow new NoSuchBeanDefinitionException(Object.class);\n\t\t}\n\t\tT result = it.next();\n\t\tif (it.hasNext()) {\n\t\t\tthrow new NoUniqueBeanDefinitionException(Object.class, 2, \"more than 1 matching bean\");\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Return an instance (possibly shared or independent) of the object\n\t * managed by this factory.\n\t * <p>Allows for specifying explicit construction arguments, along the\n\t * lines of {@link BeanFactory#getBean(String, Object...)}.\n\t * @param args arguments to use when creating a corresponding instance\n\t * @return an instance of the bean\n\t * @throws BeansException in case of creation errors\n\t * @see #getObject()\n\t */\n\tdefault T getObject(@Nullable Object... args) throws BeansException {\n\t\tthrow new UnsupportedOperationException(\"Retrieval with arguments not supported -\" +\n\t\t\t\t\"for custom ObjectProvider classes, implement getObject(Object...) for your purposes\");\n\t}","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/e8729d043887bf0d0baf91e062e909b56eb2b708/spring-beans/src/main/java/org/springframework/beans/factory/ObjectProvider.java#L75-L111","documentation":"Error \"more than 1 matching bean\" thrown in spring-projects/spring-framework.","triggerScenarios":"Thrown at spring-beans/src/main/java/org/springframework/beans/factory/ObjectProvider.java:93 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"e8729d043887bf0d0baf91e062e909b56eb2b708","analyzedAt":"2026-08-04T19:07:39.725Z","schemaVersion":2}