Dab tsi yog qhov txawv ntawm byType thiab byName hauv caij nplooj ntoos hlav?
Dab tsi yog qhov txawv ntawm byType thiab byName hauv caij nplooj ntoos hlav?

Video: Dab tsi yog qhov txawv ntawm byType thiab byName hauv caij nplooj ntoos hlav?

Video: Dab tsi yog qhov txawv ntawm byType thiab byName hauv caij nplooj ntoos hlav?
Video: Community Solutions Grantee Spotlight: HECC 2024, Tej zaum
Anonim

Cov qhov sib txawv ntawm byType thiab byName autowiring yog raws li nram no: Autowire byType yuav nrhiav tau ib tug taum nyob rau hauv configuration ntaub ntawv, uas nws id match nrog cov cuab yeej hom yuav wired whereas autowire byNpe yuav nrhiav tau ib tug taum uas nws id yog txuam nrog cov cuab yeej lub npe yuav wired.

Cov lus nug tseem yog, Autowiring byType yog dab tsi nyob rau lub caij nplooj ntoo hlav?

Hauv Caij nplooj ntoos hlav , “ Autowiring los ntawm Hom ” txhais tau hais tias, yog cov ntaub ntawv hom taum sib xws nrog cov ntaub ntawv ntawm lwm yam khoom taum, nws pib xaim nws. Piv txwv li, "tus neeg" taum nthuav tawm cov cuab yeej nrog cov ntaub ntawv hom "muaj peev xwm" chav kawm, Caij nplooj ntoos hlav yuav pom taum nrog tib cov ntaub ntawv hom ntawm chav kawm "muaj peev xwm" thiab xaim nws tau.

Ib tug kuj tseem nug, lub hom phiaj ntawm @autowired nyob rau lub caij nplooj ntoos hlav yog dab tsi? Autowiring feature ntawm caij nplooj ntoos hlav lub moj khaum enables koj mus txhaj cov khoom dependency implicitly. Nws sab hauv siv setter lossis constructor txhaj. Autowiring tsis tuaj yeem siv los txhaj cov cim tseem ceeb thiab txoj hlua. Nws ua haujlwm nrog kev siv nkaus xwb.

Kuj Paub, muaj pes tsawg hom Autowiring nyob rau lub caij nplooj ntoos hlav?

Qhov no hu ua caij nplooj ntoos hlav taum autowiring . Cov autowiring functionality muaj plaub hom. Cov no yog 'tsis muaj', 'byName', 'byType' thiab 'constructor'. Lwm tus autowire hom autodetect tau deprecated.

Dab tsi yog kev xaim hauv caij nplooj ntoos hlav?

- Taum kab hluav taws xob yog cov txheej txheem ntawm kev sib txuas taum nrog Caij nplooj ntoos hlav thawv. Cov taum uas xav tau yuav tsum tau ceeb toom rau lub thawv thiab yuav ua li cas lub thawv yuav tsum siv cov tshuaj tiv thaiv los khi lawv ua ke, thaum lub sijhawm kab hluav taws xob cov taum.

Pom zoo: