Class FullyQualifiedAnnotationBeanNameGenerator
- java.lang.Object
- org.springframework.context.annotation.AnnotationBeanNameGenerator
- org.springframework.context.annotation.FullyQualifiedAnnotationBeanNameGenerator
- All Implemented Interfaces:
BeanNameGenerator
public class FullyQualifiedAnnotationBeanNameGenerator extends AnnotationBeanNameGenerator
An extension ofAnnotationBeanNameGeneratorthat uses the fully qualified class name as the default bean name if an explicit bean name is not supplied via a supported type-level annotation such as@Component(seeAnnotationBeanNameGeneratorfor details on supported annotations).Favor this bean naming strategy over
AnnotationBeanNameGeneratorif you run into naming conflicts due to multiple autodetected components having the same non-qualified class name (i.e., classes with identical names but residing in different packages).Note that an instance of this class is used by default for configuration-level import purposes; whereas, the default for component scanning purposes is a plain
AnnotationBeanNameGenerator.- Since:
- 5.2.3
- Author:
- Juergen Hoeller, Sam Brannen
- See Also:
DefaultBeanNameGenerator,AnnotationBeanNameGenerator,ConfigurationClassPostProcessor.IMPORT_BEAN_NAME_GENERATOR
Field Summary
Fields Modifier and Type Field Description static FullyQualifiedAnnotationBeanNameGeneratorINSTANCEA convenient constant for a defaultFullyQualifiedAnnotationBeanNameGeneratorinstance, as used for configuration-level import purposes.
Constructor Summary
Constructors Constructor Description FullyQualifiedAnnotationBeanNameGenerator()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringbuildDefaultBeanName(BeanDefinition definition)Derive a default bean name from the given bean definition.Methods inherited from class org.springframework.context.annotation.AnnotationBeanNameGenerator
buildDefaultBeanName, determineBeanNameFromAnnotation, generateBeanName, isStereotypeWithNameValue
Field Detail
INSTANCE
public static final FullyQualifiedAnnotationBeanNameGenerator INSTANCE
A convenient constant for a defaultFullyQualifiedAnnotationBeanNameGeneratorinstance, as used for configuration-level import purposes.- Since:
- 5.2.11
Constructor Detail
FullyQualifiedAnnotationBeanNameGenerator
public FullyQualifiedAnnotationBeanNameGenerator()
Method Detail
buildDefaultBeanName
protected String buildDefaultBeanName(BeanDefinition definition)
Description copied from class:AnnotationBeanNameGeneratorDerive a default bean name from the given bean definition.The default implementation simply builds a decapitalized version of the short class name: e.g. "mypackage.MyJdbcDao" -> "myJdbcDao".
Note that inner classes will thus have names of the form "outerClassName.InnerClassName", which because of the period in the name may be an issue if you are autowiring by name.
- Overrides:
buildDefaultBeanNamein classAnnotationBeanNameGenerator- Parameters:
definition- the bean definition to build a bean name for- Returns:
- the default bean name (never
null)