Dab tsi yog kev siv cov tshuaj tivthaiv scan nyob rau lub caij nplooj ntoos hlav?
Dab tsi yog kev siv cov tshuaj tivthaiv scan nyob rau lub caij nplooj ntoos hlav?

Video: Dab tsi yog kev siv cov tshuaj tivthaiv scan nyob rau lub caij nplooj ntoos hlav?

Video: Dab tsi yog kev siv cov tshuaj tivthaiv scan nyob rau lub caij nplooj ntoos hlav?
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Hlis ntuj nqeg
Anonim

Siv tivthaiv scan yog ib txoj kev nug Caij nplooj ntoos hlav mus ntes Caij nplooj ntoos hlav - tswj cov khoom . Caij nplooj ntoos hlav xav tau cov ntaub ntawv los nrhiav thiab sau npe tag nrho cov Caij nplooj ntoos hlav Cheebtsam nrog rau daim ntawv thov ntsiab lus thaum lub daim ntawv thov pib.

Tsis tas li ntawd, Classpath scanning nyob rau lub caij nplooj ntoos hlav yog dab tsi?

Caij nplooj ntoos hlav Classpath Scanning & Tswj Cheebtsam. Qhov no txhais tau tias Caij nplooj ntoos hlav muaj peev xwm auto scan , ntes thiab instantiate taum los ntawm cov phiaj xwm npaj ua ntej, yog li txuag peb ntawm cov taum tedious / cov lus tshaj tawm hauv XML cov ntaub ntawv.

Kuj Paub, qhov kev txheeb xyuas cov khoom siv ua dab tsi? Cheebtsam scanning cia li ntes cov neeg sib tw nyob sib ze nrhiav tau los ntawm classpath scanning . Thaum lub sij hawm scanning txheej txheem, Caij nplooj ntoos hlav tshawb rau cov chav kawm annotated nrog stereotype annotations. Cov annotation yog @ Cheebtsam , @Controller, @Service thiab @Repository.

Ua raws li qhov no hauv kev txiav txim siab, kuv yuav muab cov tshuaj ntsuam xyuas qhov twg?

tso @ ComponentScan nyob rau saum koj pob ntoo. Koj tseem tuaj yeem siv tus cwj pwm basePackages los qhia qhov twg los pib qhov scanning. Yog koj xav tau scan tag nrho cov chav kawm annoted, tso chav kawm sau nrog @ ComponentScan hauv com. app pob.

Kuv yuav tshuaj xyuas cov khoom hauv lub caij nplooj ntoos hlav li cas?

Thaum koj txhais a Cheebtsam Scan rau ib pob, Caij nplooj ntoos hlav yuav tshawb cov pob thiab tag nrho nws cov pob sub rau cov khoom / taum. Yog koj siv Caij nplooj ntoos hlav khau raj , xyuas kev teeb tsa hauv Txoj Kev 1. Yog tias koj tab tom ua JSP/Servlet lossis ib qho Caij nplooj ntoos hlav MVC daim ntawv thov tsis siv Caij nplooj ntoos hlav khau raj siv txoj kev 2.

Pom zoo: