spring的基本知识
生活随笔
收集整理的這篇文章主要介紹了
spring的基本知识
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
首先是回顧一下spring的基本知識(shí) 1、@controller 控制器(注入服務(wù))
2、@service 服務(wù)(注入dao)
3、@repository dao(實(shí)現(xiàn)dao訪問)
4、@component (把普通pojo實(shí)例化到spring容器中,相當(dāng)于配置文件中的<bean id="" class=""/>) ? @Component,@Service,@Controller,@Repository注解的類,并把這些類納入進(jìn)spring容器中管理。?
下面寫這個(gè)是引入component的掃描組件?
<context:component-scan base-package=”com.mmnc”>????
其中base-package為需要掃描的包(含所有子包)?
?????? 1、@Service用于標(biāo)注業(yè)務(wù)層組件?
?????? 2、@Controller用于標(biāo)注控制層組件(如struts中的action)?
?????? 3、@Repository用于標(biāo)注數(shù)據(jù)訪問組件,即DAO接口的實(shí)現(xiàn)類
?????? 4、@Component泛指組件,當(dāng)組件不好歸類的時(shí)候,我們可以使用這個(gè)注解進(jìn)行標(biāo)注。 ? ?
下面寫這個(gè)是引入component的掃描組件?
<context:component-scan base-package=”com.mmnc”>????
其中base-package為需要掃描的包(含所有子包)?
?????? 1、@Service用于標(biāo)注業(yè)務(wù)層組件?
?????? 2、@Controller用于標(biāo)注控制層組件(如struts中的action)?
?????? 3、@Repository用于標(biāo)注數(shù)據(jù)訪問組件,即DAO接口的實(shí)現(xiàn)類
?????? 4、@Component泛指組件,當(dāng)組件不好歸類的時(shí)候,我們可以使用這個(gè)注解進(jìn)行標(biāo)注。 ? ?
轉(zhuǎn)載于:https://www.cnblogs.com/bravolove/p/5029238.html
總結(jié)
以上是生活随笔為你收集整理的spring的基本知识的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 家用投影机选哪个牌子好?
- 下一篇: Gson解析Json格式数据