1, @controller Controller (injection service) 2, @service Service (injection DAO) 3, @repository DAO (Implement DAO Access) 4, @component (the normal pojo is instantiated into the spring container, equivalent to the configuration file <bean id= "" class= ""/>)
@Component, @Service, @Controller, @Repository annotated classes, and incorporate these classes into the spring container for management.
The following is a scan component that introduces component
<context:component-scan base-package= "COM.MMNC" >
Where Base-package is the package that needs to be scanned (with all child packages)
1, @Service for labeling business layer components
2. @Controller for labeling Control-layer components (such as action in struts)
3. @Repository is used to label data access Components, DAO components.
4, @Component refer to the components, when the component is not good to classify, we can use this annotation for labeling.
@Service public class Userserviceimpl implements UserService {}
The default name for the @Repository public class Userdaoimpl implements Userdao {} Getbean is the class name (lowercase letters) and if you want to customize it, you can @service ("* * *") This specifies that the bean is singleton by default, and if you want to change it, you can use @service ("Beanname")
@Scope ("prototype") to change. You can specify the initialization method and the Destruction method (method name arbitrary) by using the following method: @PostConstruct public void init () {}
Spring Annotations in detail