when I use getBean("test")
I have a class like
@Component
public class TEST {
}
can this bean be loaded?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
getBean()is case sensitive, however Spring uses custom bean naming strategy for@Componentand@Beanclasses. See 4.10.5 Naming autodetected components:And for
@Configuration/@Beansee 4.12.4.5 Customizing bean naming:Back to your question. Because your class is not following Java naming conventions (camel-case names) Spring uses unusual name for the bean, this will work:
However if you use expected naming (
@Component class Test { }), you must use lower-case identifiers:Moreover if your name is more complex, uncapitalized camel-case syntax applies (continuing to quote the Spring documentation):