Video: Dab tsi yog kev siv cov tshuaj tivthaiv scan nyob rau lub caij nplooj ntoos hlav?
2024 Tus sau: Lynn Donovan | [email protected]. Kawg hloov kho: 2023-12-15 23:47
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:
Dao chav kawm nyob rau lub caij nplooj ntoos hlav yog dab tsi?
Nws yog tus qauv tsim nyob rau hauv uas cov ntaub ntawv nkag mus siv khoom (DAO) yog ib yam khoom uas muab qhov kev paub daws teeb meem rau qee hom database lossis lwm yam kev ua haujlwm ruaj khov. Lub caij nplooj ntoos hlav cov ntaub ntawv nkag mus rau lub moj khaum yog muab los koom ua ke nrog cov txheej txheem sib txawv xws li JDBC, Hibernate, JPA, iBatis thiab lwm yam
Cron kev qhia yog dab tsi nyob rau lub caij nplooj ntoos hlav?
Ib qho Cron qhia muaj rau qhov ua ntu zus - thib ob, feeb, teev, hnub ntawm lub hli, hli, hnub (s) ntawm lub lim tiam.thiab tau tshaj tawm raws li hauv qab no @Scheduled(cron = '* * * * **')
Kev siv @value annotation nyob rau lub caij nplooj ntoos hlav yog dab tsi?
Spring @PropertySource annotations yog tsuas yog siv los nyeem los ntawm cov ntaub ntawv khoom siv Spring's Environment interface. Cov lus piav qhia no yog nyob rau hauv kev xyaum, muab tso rau ntawm @Configuration chav kawm. Caij nplooj ntoos hlav @Value annotation tuaj yeem siv los qhia cov lus qhia ntawm daim teb lossis txoj hauv kev. Cov ntaub ntawv siv feem ntau yog qhia cov cuab yeej los ntawm a
Kev siv Autowired annotation nyob rau lub caij nplooj ntoos hlav yog dab tsi?
Spring @Autowired annotation yog siv rau kev txhaj tshuaj tsis siv neeg. Spring moj khaum yog tsim los ntawm kev vam khom kev txhaj tshuaj thiab peb txhaj cov chav kawm dependencies los ntawm lub caij nplooj ntoos hlav taum configuration file
Lub ntsiab lus configuration nyob rau lub caij nplooj ntoos hlav yog dab tsi?
Lub Caij Nplooj Ntoos Zeeg yog dab tsi? Caij nplooj ntoos hlav ntsiab lus tseem hu ua Spring IoC ntim, uas yog lub luag hauj lwm rau instantiating, configuring, thiab assembling taum los ntawm kev nyeem configuration metadata los ntawm XML, Java annotations, thiab / los yog Java code nyob rau hauv cov ntaub ntawv configuration