Is spring getbean case sentitive or not?

后端 未结 2 1375
小蘑菇
小蘑菇 2021-02-05 09:43

when I use getBean(\"test\")

I have a class like

@Component
public class TEST {
}

can this bean be loaded?

2条回答
  •  既然无缘
    2021-02-05 10:05

    @Component annotation uses AnnotationBeanNameGenerator by default which, if not explicitly given a name, will use Introspector.decapitalize() method on the bean ClassName to get a name for the bean. Normally a class with name like "Test" will give it bean name "test". But decapitalize has a curiosity:

    This normally means converting the first character from upper case to lower case, but in the (unusual) special case when there is more than one character and both the first and second characters are upper case, we leave it alone.

    So your class TEST will get bean name TEST.

提交回复
热议问题