getBean<T extends Object> abstract method

T getBean<T extends Object>({
  1. String? qualifier,
})

The bean of type T, created if it does not exist yet. With qualifier, only the bean with that name, alias or @Qualifier value.

When several beans match, the winner is the single @Primary one, else the only one not marked @Fallback, else the one whose name or alias is qualifier, else the one with the lowest jakarta @Priority, else the only default candidate. Like Spring's getBean(Class), beans that are not autowire candidates count only when they are the only matches, and a qualifier can select any bean. This factory's beans are looked up first, then the objects of registerResolvableDependency (Spring's getBean ignores those), then the parent.

Throws NoSuchBeanDefinitionException when nothing matches (a bean whose @Bean method returned null counts as missing) and NoUniqueBeanDefinitionException when several match and none wins.

// Two Greeter beans; this one is wanted.
final greeter = factory.getBean<Greeter>(qualifier: 'french');

Spring: getBean(Class); with a qualifier, getBean(name, Class) or BeanFactoryAnnotationUtils.qualifiedBeanOfType.

Implementation

T getBean<T extends Object>({String? qualifier});