Cov lus piav qhia PreDestroy yog siv rau txoj hauv kev raws li kev ceeb toom hu rov qab los qhia tias qhov piv txwv tab tom raug tshem tawm los ntawm lub thawv. Txoj kev piav qhia nrog PreDstroy feem ntau yog siv los tso cov peev txheej uas nws tau tuav.
Vim li cas peb thiaj siv @PostConstruct?
Cov lus piav qhia PostConstruct yog siv rau ib txoj hauv kev uas yuav tsum tau ua tom qab kev vam khom kev txhaj tshuaj ua tiav los ua ib qho pibTxoj kev no yuav tsum tau hu ua ntej chav kawm muab tso rau hauv kev pabcuam. Cov lus piav qhia no yuav tsum tau txais kev txhawb nqa rau txhua chav kawm uas txhawb kev txhaj tshuaj tiv thaiv.
Puas PostConstruct yog tus kheej?
Txoj kev uas PostConstruct raug siv yuav yog public, tiv thaiv, pob khoom ntiag tug lossis ntiag tug. Txoj kev YUAV TSUM TSIS zoo li qub.
@PostConstruct annotation nyob rau lub caij nplooj ntoo hlav yog dab tsi?
@PostConstruct yog lus piav qhia siv rau ntawm txoj hauv kev uas yuav tsum tau ua tom qab kev vam khom kev txhaj tshuaj kom ua tiav qhov pib.
Vim li cas PostConstruct tsis hu?
Java EE taum annotations xws li @PostConstruct tsuas yog siv tau rau cov taum tswj lub thawv. Yog tias koj tsuas yog hu xov tooj tshiab BlogEntryDao koj tus kheej, lub thawv isn tsis mus cuam tshuam kev tsim thiab hu rau @PostConstruct method.