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 specify it @service ("* * *"), This bean is a 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