一、@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容器中進行管理