@value ua dab tsi thaum caij nplooj ntoos hlav?
@value ua dab tsi thaum caij nplooj ntoos hlav?

Video: @value ua dab tsi thaum caij nplooj ntoos hlav?

Video: @value ua dab tsi thaum caij nplooj ntoos hlav?
Video: Maiv Xyooj ~"Nco Koj Thaum Lub Caij Nplooj Ntoos Zeeg" with Lyrics (Original Music Video) 2024, Hlis ntuj nqeg
Anonim

Caij nplooj ntoos hlav @ Tus nqi lus piav qhia yog siv los muab default tus nqi rau variables thiab method arguments. Peb ua tau nyeem caij nplooj ntoos hlav ib puag ncig variables raws li zoo raws li qhov system variables siv @ Tus nqi lus piav qhia. Caij nplooj ntoos hlav @ Tus nqi annotation kuj txhawb SpEL.

Hais txog qhov no, kev siv @value annotation yog dab tsi?

Caij nplooj ntoos hlav @ Nqe lus piav qhia yog siv los txhaj tus nqi nyob rau hauv variables thiab method arguments. Peb tuaj yeem nyeem qhov hloov pauv ib puag ncig caij nplooj ntoos hlav lossis lub cev hloov pauv. Nws kuj txhawb SpEL.

Tsis tas li ntawd, koj txhaj tshuaj Spring values li cas? Yuav ua li cas txhaj tus nqi rau hauv Bean cov khoom hauv Caij nplooj ntoos hlav

  1. Tsim ib qhov project Maven tshiab. Mus rau Cov Ntaub Ntawv -> Project -> Maven -> Maven Project.
  2. Ntxiv Caij nplooj ntoos hlav 3.2. 3 kev vam meej.
  3. Tsim ib qho yooj yim Spring Bean nrog cov khoom.
  4. XML-raws li txoj hauv kev rau kev txhaj tshuaj rau hauv cov khoom taum.
  5. Khiav daim ntawv thov.
  6. Tso zis.

Raws li txoj cai, cov lus piav qhia ua haujlwm li cas thaum caij nplooj ntoos hlav?

Feem ntau, cov lus piav qhia tso cai rau koj ntxiv metadata rau hauv chav kawm, txoj kev los yog hloov pauv. Ib lus piav qhia tuaj yeem txhais los ntawm cov neeg sau ntawv (piv txwv li, @Override lus piav qhia ) lossis los ntawm lub moj khaum xws li caij nplooj ntoos hlav (piv txwv li, @Component lus piav qhia ).

Peb puas tuaj yeem txhaj tshuaj tsis muaj nuj nqis thiab cov hlua khoob hauv lub caij nplooj ntoo hlav?

Yog koj xav tau txhaj null nqi rau txhua qhov chaw hauv Caij nplooj ntoos hlav ces siv qhov tshwj xeeb < null /> lub ntsiab rau nws, tsis txhob siv tus nqi =” null ”vim tias yuav hla " null "as a Txoj hlua tus nqi . Siv < null /> element hloov hauv koj Caij nplooj ntoos hlav kev teeb tsa. Qhov ntawd yog txhua yam rau lub ncauj lus no Yuav ua li cas Txhaj Null Thiab Empty String Values in Spring.