Dab tsi yog kev siv ntawm @repository annotation nyob rau lub caij nplooj ntoo hlav?
Dab tsi yog kev siv ntawm @repository annotation nyob rau lub caij nplooj ntoo hlav?

Video: Dab tsi yog kev siv ntawm @repository annotation nyob rau lub caij nplooj ntoo hlav?

Video: Dab tsi yog kev siv ntawm @repository annotation nyob rau lub caij nplooj ntoo hlav?
Video: Leng Yang - Yog Vim Dab Tsi (Official Full Song | Nkauj Tawm Tshiab) 2020/05/24 2024, Hlis ntuj nqeg
Anonim

Caij nplooj ntoos hlav @ Repository Annotation . Caij nplooj ntoos hlav @ Repository annotation yog siv los qhia tias chav kawm muab cov txheej txheem rau kev khaws cia, rov qab, tshawb nrhiav, hloov kho thiab tshem tawm cov haujlwm ntawm cov khoom.

Yog li ntawd, @repository annotation ua dab tsi?

Cov @ Repository annotation yog tus cim rau txhua chav kawm uas ua tiav lub luag haujlwm lossis kev xav ntawm a chaw cia khoom (tseem hu ua Data Access Object lossis DAO). Ntawm cov kev siv ntawm tus cim no yog kev txhais tsis siv neeg ntawm kev zam raws li tau piav qhia hauv Tshooj 20.2. 2, "Kev txhais lus tshwj xeeb".

Kuj Paub, qhov txawv ntawm @component @controller @repository thiab @service annotations nyob rau lub caij nplooj ntoos hlav yog dab tsi? Cov qhov sib txawv ntawm lawv yog , @ tiv thaiv yog siv rau sau ntawv cov chav kawm compound, @ Repository yog ib lub cim rau tsis siv neeg zam kev txhais lus hauv persistence txheej, rau kev pabcuam txheej peb yuav tsum siv @ kev pabcuam . Koj tuaj yeem xa mus Caij nplooj ntoos hlav Cov ntaub ntawv kom paub ntau ntxiv.

Tom qab ntawd, lo lus nug yog, dab tsi yog qhov kev pabcuam hauv lub caij nplooj ntoo hlav?

Caij nplooj ntoos hlav @ Service annotation yog qhov tshwj xeeb ntawm @Component lus piav qhia . Spring Service annotation tuaj yeem siv rau cov chav kawm xwb. Nws yog siv los kos cov chav kawm ua a kev pabcuam tus muab kev pab.

@transactional ua haujlwm li cas hauv Caij Nplooj Ntoos Hlav?

Nkag siab @ Kev lag luam lus piav qhia. Nyob rau theem siab, thaum ib chav kawm tshaj tawm @ Kev lag luam ntawm nws tus kheej lossis nws cov tswv cuab, Caij nplooj ntoos hlav tsim ib lub npe uas siv tib lub interface (s) raws li cov chav kawm koj nyob nraum annotating. Hauv lwm lo lus, Caij nplooj ntoos hlav qhwv cov taum hauv lub npe thiab cov taum nws tus kheej tsis paub txog nws.