In the Annotaion configuration note, @component is used to represent a generic comment to illustrate that a class is a spring container-managed class. That is, the class has been pulled into the management of spring. And @controller, @Service, @Repository is the refinement of @component, these three annotations with more semantics than @component, they correspond to the control layer, service layer, the class of the persistence layer respectively.
The @Repository tag is used to define a name for the class of the persistence layer, so that spring is associated with the class based on the name.
For example:
@Repository ("Userdao")
public class Userdaoimpl implements userdao{
........................................
}
Declares the name of Userdaoimpl in the spring container called Userdao.
The @Service is a Iserviceimpl class file for the service layer, similar in function to @repository.
Another tag: @autowired is used to inject.
For example:
@autowired
Private Userdao Userdao;
This is injected into the equivalent of a new implementation class, so we don't have to write setter methods.
We also have to have configuration files to configure:
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.