Polishing
This commit is contained in:
@@ -381,8 +381,8 @@ public class GenericApplicationContext extends AbstractApplicationContext implem
|
||||
* @param beanName the name of the bean (may be {@code null})
|
||||
* @param beanClass the class of the bean (resolving a public constructor
|
||||
* to be autowired, possibly simply the default constructor)
|
||||
* @param customizers one or more callbacks for customizing the
|
||||
* factory's {@link BeanDefinition}, e.g. setting a lazy-init or primary flag
|
||||
* @param customizers one or more callbacks for customizing the factory's
|
||||
* {@link BeanDefinition}, e.g. setting a lazy-init or primary flag
|
||||
* @since 5.0
|
||||
* @see #registerBean(String, Class, Supplier, BeanDefinitionCustomizer...)
|
||||
*/
|
||||
|
||||
@@ -105,6 +105,24 @@ public class AnnotationConfigApplicationContextTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getBeanByTypeAmbiguityRaisesException() {
|
||||
ApplicationContext context = new AnnotationConfigApplicationContext(TwoTestBeanConfig.class);
|
||||
|
||||
try {
|
||||
context.getBean(TestBean.class);
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
assertThat(ex.getMessage(),
|
||||
allOf(
|
||||
containsString("No qualifying bean of type '" + TestBean.class.getName() + "'"),
|
||||
containsString("tb1"),
|
||||
containsString("tb2")
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that Configuration classes are registered according to convention
|
||||
* @see org.springframework.beans.factory.support.DefaultBeanNameGenerator#generateBeanName
|
||||
@@ -370,14 +388,6 @@ public class AnnotationConfigApplicationContextTests {
|
||||
}
|
||||
}
|
||||
|
||||
static class ConfigMissingAnnotation {
|
||||
|
||||
@Bean
|
||||
public TestBean testBean() {
|
||||
return new TestBean();
|
||||
}
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class TwoTestBeanConfig {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user