Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8048645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:30:31+00:00 2026-06-05T06:30:31+00:00

when I use getBean(test) I have a class like @Component public class TEST {

  • 0

when I use getBean("test")

I have a class like

@Component
public class TEST {
}

can this bean be loaded?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:30:34+00:00Added an answer on June 5, 2026 at 6:30 am

    getBean() is case sensitive, however Spring uses custom bean naming strategy for @Component and @Bean classes. See 4.10.5 Naming autodetected components:

    When a component is autodetected as part of the scanning process, its bean name is generated by the BeanNameGenerator strategy […]. By default, any Spring stereotype annotation (@Component, @Repository, @Service, and @Controller) that contains a name value will thereby provide that name to the corresponding bean definition.

    If such an annotation contains no name value or for any other detected component (such as those discovered by custom filters), the default bean name generator returns the uncapitalized non-qualified class name.

    And for @Configuration/@Bean see 4.12.4.5 Customizing bean naming:

    By default, configuration classes use a @Bean method’s name as the name of the resulting bean. This functionality can be overridden, however, with the name attribute.

    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:

    getBean("TEST")
    

    However if you use expected naming (@Component class Test { }), you must use lower-case identifiers:

    getBean("test")
    

    Moreover if your name is more complex, uncapitalized camel-case syntax applies (continuing to quote the Spring documentation):

    […] For example, if the following two components were detected, the names would be myMovieLister and movieFinderImpl:

    @Service("myMovieLister")
    public class SimpleMovieLister {
      // ...
    }
    
    @Repository
    public class MovieFinderImpl implements MovieFinder {
      // ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view-scoped bean ManageFoo.java: @ManagedBean(name = ManageFoo) @ViewScoped public class ManageFoo {
i make one class file for jar. and this class have use wurfl. and
In a util class I want to use one of my services. Now this
We use spring to construct/inject our java beans. Here a snippet: <bean id=myAppConfigs class=my.cool.webapp.ApplicationConfig
I have this configuration on my web application. 2 beans : 1° Bean -
According to what I have found so far, I can use the following code:
I have a ServiceListFactoryBean which creates a list of service implementations: <bean id=services class=org.springframework.beans...ServiceListFactoryBean
I have a Spring application (Spring Batch not web application). In a test class,
Suppose have following beach definition: <bean id=singletonBean class=...> <property name=instanceBean ref=instanceBean/> </bean> <bean id=instanceBean
I have a java class LayoutManager.java, which I pass as a Sprean Bean into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.