Cov txheej txheem:

Muaj pes tsawg hom taum caij nplooj ntoos hlav muaj?
Muaj pes tsawg hom taum caij nplooj ntoos hlav muaj?

Video: Muaj pes tsawg hom taum caij nplooj ntoos hlav muaj?

Video: Muaj pes tsawg hom taum caij nplooj ntoos hlav muaj?
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Plaub Hlis Ntuj
Anonim

Nyob rau hauv lub caij nplooj ntoos hlav taum configurations, taum attribute hu ua 'scope' txhais tias yam khoom twg muaj los tsim thiab xa rov qab. Muaj muaj 5 yam ntawm taum scopes muaj, lawv yog: 1) singleton: Rov qab ib qho piv txwv taum ib lub caij nplooj ntoos hlav IoC thawv.2) qauv: Rov qab taum tshiab txhua zaus thaum thov.

Dhau li ntawm no, dab tsi yog qhov txawv ntawm lub caij nplooj ntoos hlav taum?

Los ntawm lub caij nplooj ntoos hlav specs, muaj tsib hom taum scopes txhawb nqa:

  • singleton(default*) Scopes ib leeg taum txhais rau ib qho khoom piv txwv ib lub thawv Spring IoC.
  • tsab ntawv. Scopes ib leeg taum txhais rau txhua tus lej ntawm cov khoom piv txwv.
  • thov.
  • kev sib tham.
  • kev sib tham thoob ntiaj teb.

Tsis tas li, muaj pes tsawg txoj hauv kev uas peb tuaj yeem tsim taum nyob rau lub caij nplooj ntoo hlav? Muaj tsib qhov kev txiav txim siab rau Caij nplooj ntoos hlav taum .singleton – Tsuas yog ib piv txwv ntawm taum yuav ua tsim rau txhua lub thawv. Qhov no yog lub default Scope forthe taum caij nplooj ntoos hlav.

Ib yam li ntawd ib tug yuav nug, dab tsi yog ntau hom ntawm lub caij nplooj ntoos hlav taum Autowiring?

Cov autowiring functionality muaj tsib hom. Cov no yog 'tsis muaj', 'byName', 'byType', 'constructor', thiab 'autodetect'. Lub neej ntawd hom yog "tsis muaj" piv txwv li bydefault autowiring yog muab tua nyob rau hauv ib txwm XML raws li configuration. 1) Lub neej ntawd hom nyob rau hauv ib txwm XML raws li configuration yog tsis muaj.

Dab tsi yog hom taum hauv Java?

Kev sib tham taum yog ntawm peb hom : stateful, stateless, thiab singleton.

Pom zoo: