The default bean names that are labeled with @component, @Repository, @Service, and @Controller in spring are unqualified class names beginning with lowercase

Source: Internet
Author: User

When you use the dispatch platform today to invoke a method in the bean, you are prompted not to find the bean. It was found that if the name attribute value is not provided on the label, the default bean name starts with lowercase instead of uppercase.

Here are the other documents to see:

Use filters to customize the scan <context:component-scan base-package= "Org.example" >
This is written in the Spring Development manual:
3.12.4. Naming the components automatically detected

When a component is automatically detected during a scan, its bean name is generated based on the Beannamegenerator policy of that scanner. By default, any spring "typical" annotations (@Component, @Repository, @Service, and @controller) that contain a name value provide that name to the relevant bean definition. If the annotation does not contain a name value or other detected component (such as found by a custom filter), the default bean name generator returns the unqualified (non-qualified) class name at the beginning of the lowercase. For example, if the following two components are found, their names will be ' mymovielister ' and ' Moviefinderimpl ':

@Service ("Mymovielister")
public class Simplemovielister {
// ...
}

@Repository
public class Moviefinderimpl implements Moviefinder {
// ...
}

"Reference Document"

1.http://bbs.csdn.net/topics/350149265

2.http://blog.csdn.net/yi3040/article/details/6447289

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.