一、@controller 控制器(注入服务)spring
二、@service 服务(注入dao).net
三、@repository(实现dao访问)code
四、@component (把普通pojo实例化到spring容器中,至关于配置文件中的
<bean id="" class=""/>
)component
案例: <context:component-scan base-package=”com.*”> 上面的这个例子是引入Component组件的例子,其中base-package表示为须要扫描的全部子包。 共同点:被@controller 、@service、@repository 、@component 注解的类,都会把这些类归入进spring容器中进行管理