Description
Expected Behavior
When a class is annotated only with @Named
annotation and asked for injection then the bean locator throws NoSuchBeanException
because of missing scope annotation such as @Singleton
Actual Behaviour
@Named
annotation works as a synonym for @Bean
and implies prototype scope. Every time the bean locator is asked for the bean, the new one is created.
Steps To Reproduce
- create a bean with only
@Named
annotation such as@Named("foo") public class NamedBean { }
- create injection point or ask bean locator for the bean
beanLocator.getBean(NamedBean.class)
- new instance of the bean is created every time you ask for the bean
Environment Information
No response
Example Application
https://github.com/musketyr/named-annotation-bean-issue for reproducer
Version
4.7.6
Metadata
Metadata
Assignees
Labels
No labels