The role of @component in "turn" spring

Source: Internet
Author: User

Today, when writing a program, I saw a note (@Component) that I had not seen before, and after searching the web, I decided to record it after practice.
1. @controller controller (injection service)

    • Used to label the control layer, equivalent to the action layer in struts

2. @service service (injected into DAO)

    • Used for labeling service tiers, primarily for business logic processing

3. @repository (for DAO Access)

    • Used to label the data access layer, or to label data access Components, DAO components.

4, @component (the normal pojo is instantiated into the spring container, the equivalent of the configuration file
<bean id="" class=""/>

    • Refers to various components, that is, when our class is not in the various categories (not @controller, @Services, etc.), we can use @component to label this class.

Case:
<context:component-scan base-package=”com.*”>
The above example is an example of the introduction of the component component, where base-package is represented as all the sub-packages that need to be scanned.
Common denominator: Classes that are annotated by @controller, @service, @repository, @component will be managed by incorporating these classes into the spring container

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced. 78558010

The role of @component in "turn" spring

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.