版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、SpringBoof攒违巴-tEstSpring帀Edeawcl 巾kspwtzRHestRringjEEdEBWOek;5pwnml5prHgboR-snArnainla-vi-Refacsr豎丘R RTOQ-Ev(s匡 rdsNopop血 riCRL-CRL- = =opmrl宅 czmmH Htttt z?z? _p_p昼吿甲 3事 Java 聖可 p 去ea-a-?*je4佃口苏-% It jn;FJ J=圣-a-蛋fffvisCRLoPTMJkaAu-eytKKlfwfwosfopnxljon匸ssbdbds s rtonbrtonbZJniZJni/%/%9N2罗卫eci-A召 r
2、ing一JASFK盏nd&dProProjecject tSFtSFtudaudatBtB炽r2qr2qTvpr.Eng匚灌T T*rljor*iaininf frrrripiptitiPdC監常s s Z4fZ4f prtsprtsF Foaoap4p4ndndBnBnc*c*c c_sm_sm片rrtoMfivmprc”LawPSPS产MASHOrUn 30DnrncEatct.击rw w萤npc纟,Enafnpfl-dmrTloEgEgngng aaaa2A2AWVWVseselelectctededDeDepEpEndndmcmc-3-3-一a a g g咅口翼字 V 牯 b口
3、晋ERepogrisn*4n*4|星0 0工3 3 !_!_mrovwrmrovwr HATTOASHATTOAS获取配置文件中得属性值r - r,publicpublic cljksscljkss UyConfif?UyConfif? 1 1 ) )Klccal.Klccal.ID)privateprivate 5tTjns5tTjns ip;ip;privateprivate EnviyonnLentEnviyonnLent envirentenvirent: :pubLpubL icic voidvoid showshowh h+ + ifMifM; b b enviroMient.en
4、viroMient. fftPiopertfftPiopert C*loc*l.C*loc*l. port*)port*) ) ): :I: n2 -li I I T Ipubpub 1 1 i i u u clcl assass 3pri3pri ngooDtngooDt A A ppippi icationicationpublicpublic staticstatic voidvoid aciniStrinEaciniStrinE h hcociux:cociux: = = S S rHeatrHeat ioci.ioci. jw?(Sprileboc:ijw?(Sprileboc:ic
5、 cAtAt ion,ion, c c 1 1 assass, , armarm和,context.context. getSeangetSean (UyCtmf(UyCtmf Ig.Ig.L L】町0 0 . . showshow;. .coLtejt.coLtejt.closeclose ( ( I I , ,件或者路径)1.通过配置方式System,System,out.out.printlrprintlr ipip: System,System,out.out.printlnprintln LportLport: :CoRfCoRf辽urur自bZAMLuajbZAMLuaj iort
6、tornexTiorttornexT修改配置文件名与文件路径(可指定多个文2.通过编码方式(用这种比较好些)二十 L L A*leA*le 3 3* * ppringCwppringCw&钿曲pEwirrpEwirr-DVCAUIIIH.H. rrwrrw -i-ir rTjmotATjmotA pppp I I u u咋anan iha*Tiha*T冈jr-pnrrjr-pnrrortfortf RLrcbugiRLrcbugi iLarfigriLarfigr itio-qsitio-qs-d d护 “V V j j IpKrtfIpKrtf twtw,2 2 DMUttflDMU
7、ttfl對cpfcriKcpfcriK? ? rgqrgq ran*ran*I I r-?Mie-ewtn5*r-?MiepFir“知LALA戸ulLTunulLTun述iifmBiHiwctgFTiifmBiHiwctgFTtttllrrnnrMtttllrrnnrM脚rcrc EgEg SomrigGSomrigGH 甫置十.孑I IE?rbuE?rbu DLrputDLrput| 也*B BA A日 匡ErrWr-ErrWr- auraur rplirrir-rtnrplirrir-rtn同En/pieEn/pie塑K K sgeosgeofiMfiMPfaHXPfaHXC C冃ribJ
8、fdribJfdNirr-Nirr-V4V4I I计爭M MQ QAfjpr-Afjpr- *1*1;山由曲*EjncnlEjncnl I I占JliTKTJliTKT SpiSpi pglKmpglKm P5lP5l k k rrticFrrticFISnSjfafiWB-flSnSjfafiWB-fl I I CdtCciBf*!CdtCciBf*! jwjw | | u&u& 11如眄晁駅dpndpnfertucfertuc clan.clan.童和-rocrr-rocrr玄屮叭MESrj-MESrj-UE4C.llE!drUE4C.llE!dr nUdfalDnUdfa
9、lD:. .tpiborftpiborf5Er5ErSfhPfSfhPf RMIRMI if,if,肝 腳吐士MlbdMlbd DLAfHIDLAfHI弓 bid*bid*Q Q knihlknihlLjLj他h h BdllnUfnBdllnUfn LdlLdl CiMfataCiMfata JAftJAft AguMAguMActiveActive f-adibs:f-adibs:wikhwikh pvafTuianpvafTuianH H占iveive hcrihcri bj_.nchbj_.nchArdvafed-iMiiArdvafed-iMii H H H H- -n n Sbow
10、tHiSbowtHi PF*PF* llAftnrtAftnrt -g.-g.K K I I I I:占 ZI I firfir h h二*classpath:db,classpath:db, properties*properties* publicpublic classclassFileCosfigR 匸I I m m( (classpath:config/dbl.classpath:config/dbl. proEJerties)proEJerties), ,(/classpath(/classpath; confconf ig?Mb2.ig?Mb2. propertiesproper
11、tiespublicpublic classclass FiieConfigFiieConfig上图就是两种方式,上面一种就是加载一个文件,下面一种就是加载多个文件publirpublir classclass JdbcfonfJdbcfonfmlml=厂1 1朝”1616 . . 1.1. 1 1 10)10)privateprivate StringString ip1ip1; ; V V ll-ll-訂飞dbl.dbl. portport)privateprivate StringString pertpert 1 1: :;-.1-.1- - -Wb2Wb2” ipripr) )pri
12、vateprivate StrinjStrinj ip2ip2:=.1=.1 - -; (*$4db2.pQr+(*$4db2.pQr+: i i privitepriviteStringString jMirtS:jMirtS:publpubl vAidvAid霸howt)howt)SvxtPF,SvxtPF, oHt;oHt; pripri nTinnTiniplipl : + + iplipl + + portlportl: : + + portport 1 1J J - -S/STs,S/STs, outout: Drir.tlnl/ipSDrir.tlnl/ipS: * * * *
13、ip3ip3 + + *,*, port2port2: * *丄portSJportSJ : :cubiiccubiic classclass SprinfibcwtApplicatioaSprinfibcwtApplicatioapublicpublic staticstatic voidvoid iiginlScrLrs.iiginlScrLrs. arg?)arg?)1111 f f i i gijgij rhbrhb 1 1 AppApp 1 1 icaica t t i i oioi iCiCJIJI i iT T? ?x x T T i i:oiiTeiToiiTeiT - - J
14、iuJiu,iiLgAppiiLgApp lala tittit LfiJi,LfiJi, 22剔*丫i.Wpni.Wpn ngngioirioir t t lais.lais.( (HIT*(HIT*丫I?I? BprBpr加旳UyCoiifiUyCoiifi f.f. clftwsclftws卜.5bow5bow (I(I : :contyt.contyt.JdtKConfiJdtKConfi g-g- clcl assass I.I. showiishowii - - ccHitesT.ccHitesT. closiclosi; ;3.注入集合要注意得就是:在注入集合得时候,代码中得集合
15、一定要有get与set方法,并且集合名要与除前缀之外得属性名相同。在初始化得时候spring boot就会去上述两种情况加载得文件中去找前缀就是ds得属性。下面得ConfigurationProperties注解中有两个属性,一个就是prefix即前缀,一个就是locations即本地文件路径。如果只写前缀,那么prefix=可以省略,此时会从已加载得配置文件中去找对 应得属性,如果指定locations得话,prefix=也不能省略此时会从locations指定得文件中去找 对应得属性。ds. hosts01-192. 168. 1. 10d5.hostsl = 192. 168. k 11
16、ds.ds. hosts2hosts2 = = 192.192. 168.168. I.I. 1212ds, portsM=800(ddddportsLlj=S001ds*ds*tX3rtsr2=600弩口圧1弋匕运4- r甲削4芒帀蟲秋冷K斗上跆he門的跆 存JPHfl甘吋忙publicpublic classclass CoiLecTLonConfCoiLecTLonConf就会芳F务TIL或日押,sisi女沖巾空刚由*器privateprivate LiercStringLiercString:- - hostshosts = = newnew肚丫苛Liw:】。;:妲的庫今占孚峻-(史呻
17、二际前探七卜的耀 生三一悴并H酸写百十和=-方退;publicpublic LiLi rr getHcsts(.6getHcsts(.6returnreturn hosts;hosts;publicpublic VoidVoidst?llliJLtsst?llliJLts CList-StiCList-Sti iLifi,iLifi, hosthost酣thizi.thizi. hostshosts = = Eost5Eost5 ; ;publicpublicStringString toStrintoStrin()()returnreturn匚ollectionConfollectionCo
18、nfiflifl * + + + hostshosts - -丁 ;publicpublic voidvoid show()show()System.System. r.r. prinTlnprinTln (hosts.(hosts. sLseOsLseO + + , + + thth i i s.s. toString().toString().不同得环境读取不同得配置文件1 11.1.pubpub 1 1 c c classclass SprSpri injbcDtAppnjbcDtApp 1 11ca1ca1 11onDev1onDevpublicpublic staticstatic
19、voidvoid JiiJii LnStiiiiglLnStiiiiglELLELLS S SrSr: :r.pAppIr.pAppIi iPRXionion appliratapplirat ir-ir- = = nrwnrw SprineApplSprineAppl icatitwifSprinebootAppli/fliicatitwifSprinebootAppli/fli ioaDsv.ioaDsv. class)class): : aupLicalion.aupLicalion.selAddilionaLPforilesi/devii.selAddilionaLPforilesi/
20、devii.軟*177$*177$ i i M M;亍片配且立哺ConfConf L,eurableAfJCL,eurableAfJC 1 1 i icatcatlonConteztlonContezt contextcontext = = asplicatLon.asplicatLon. runrun (ajes(ajes ; ;S-sT*S-sT*応/ /priTiTltUccTiTfXT.priTiTltUccTiTfXT. amTEnviroiTCiPcT.amTEnviroiTCiPcT. E E TprflpprTyTprflpprTydpv.dpv. ipip )3)3 : :S
21、ystfiE.SystfiE. fWfW . . p p 1 1 iKllnJcantdxtiKllnJcantdxt一getEgetE】i i、irciwentirciwent U.U.昌etPrspertyetPrsperty Cdijv.Cdijv. poft*)poft*) content.content. clcseOclcseO . .3 3目ppNpertiesppNperties冠pertiesflfl p p p p fication-tesl.pfication-tesl.p roperticsr
22、opertics矿-T.ir-T.irpublpubl icic clcl assass SpringbcHJt.plicRtionDzSpringbcHJt.plicRtionDzpublpubl icic staticstatic vcidvcid aainIStringaainIString2J2J args)args)? ?prpr 1111:i icacaL1L1 oiloil aupJicatiauaupJicatiau = = n*n* yryrlUfi-AjjiBlUfi-AjjiB 1 1 icaticati ionon( (SpiSpi iiL?boot.iijpliiL?
23、boot.iijpli icatcatioiiDuioiiDu . . 1111 assjassj . . application.application.setAcdiTionzlPiqfile?setAcdiTionzlPiqfile? l l atest)atest) : :也亡件卷以,- -tr-tr-給;t t曰艷豆”丁ConfConf 1 15urabl5urabl f fAppLAppLi icttctti iotiConiotiConie econtentcontent = = ipplicfttiomipplicfttiom runruniai*M)iai*M); ;SysT
24、c,SysTc, fljyfljyt-t-p p riri ntnt In(In( c c ontont e exz.xz.petEnviroientpetEnviroient 0 0 . . ?e?e:P P ropertyCropertyC tsst.tsst. ip*.ip*. : :WyEipr.WyEipr.tJiit.tJiit.printprint IntcDntfKt.IntcDntfKt. .siFtHjiviramiPini.siFtHjiviramiPini U U . . SPtFrcpfrtySPtFrcpfrty tpst.tpst. pnrt)pnrt) a a
25、; ; contextcontext一cluieOcluieO r rSprin gboot自动装酉己非自动装配示例如下publxcpublxc c c丄込0IiIi3 3EiicudiiistoiiiertEiicudiiistoiiiert laulexiejitslaulexiejits LncodineG?nLncodineG?n、*:t tpublicpublic tlasMtlasM RbkEnrodiRbkEnrodi辟亡心nvertnvert iikploaontiikploaont EnodinConverEnodinConver:p p liblib lielie clas
26、sclass HncHnc cdcd i i ngfongfo niVPTtCniVPTtC orforf i.i. -jii-jii ratrat: : ononpublicpublicEnfodzEnfodzngCngCDJfDJf;-rrT-rrT cr-iTAlcr-iTAl()()returnreturn newnewVIVI SEiicSEiic DdinaDdina oeveroever 1111 h h : :皿_,:publicpublic EnrodinEfemvertEnrodinEfemvert erpsterpst站*nTwertnTwert returnreturn
27、 nt*nt* IhkEncodingCorivertIhkEncodingCorivert (Ji(Ji ; ;publicpublic clcl a a牙耳SprSpr i i qb&ntqb&nt AppApp J J i i c c atat i i onAiitonAiitO4Esemhsemh lyly ihiblLcihiblLc slulicslulic voidvoid nana丄nksifJnksifJ赵;iLigs)iLigs)f fdfifdfif 1 1illill1 1 eAppeApp 1 1 ica11ica11 (jnConres(jnConr
28、es( for.resTfor.resT = = Spr;injApjlSpr;injApjlK K T Tioni.ioni. nJLifSprinflboct.kppHfarion.nJLifSprinflboct.kppHfarion. rlnss.rlnss. Svjtetii.Svjtetii.out.out.pFipFi :t t :ieontxt-getReansOfTyptlEnfodiLigCoiitert.ieontxt-getReansOfTyptlEnfodiLigCoiitert. cliisscliiss) ). .按条件自动装配示例如下putilicputilic
29、 classclass |l4fSEnco(jirigonvert|l4fSEnco(jirigonvert iapieiientsiapieiients EncorfineConvrtEncorfineConvrtpublicpublic classclass jCbltEincodifvgConvertjCbltEincodifvgConvert iaplcaontsiaplcaonts E EneedinConverneedinConverT Tpiihpiih 1111 c c clcl ASSASS EncDdinfffrivFrTCorfEncDdinfff.l . . li/li
30、/ - - - -=D=D - . . L-L-publicpublic EjircidinEfofTivertEjircidinEfofTivert crpatpCbJonvertcrpatpCbJonvert iiii i ireturnreturn nt*nt* ChkEncodiQsCoriver(ChkEncodiQsCoriver( ( (;publicpublic :lu$lu$ UlfSConcitloEUlfSConcitloE斗CondItitHCondItitH: tmblictmblic boolbool dndn lutcbeLlutcbeL C-juciticiCo
31、atffC&iitli1C-juciticiCoatffC&iitli11 1ei:fontvxtei:fontvxt, ,AILIOta:ed1ta:ed1ada.tada.t aiirtctattdTyywUetiwialeiaiirtctattdTyywUetiwialei SirineSirine enrodinEenrodinE = = SysSys tenten jpjp時pjwfpjwf1111 c.c. FneodFneod i i nene):):returnreturn ncodinncodin nulnul 1 1 JliJli enciHlinie.en
32、ciHlinie. squaLstUTFsquaLstUTF . .: : jiji , ,: :j j叶-,A. -i II .1 frpublicpublic clubuclubu CbkCodiliciiCbkCodiliciiConditionConditionpublicpublic hfKiI*iinhfKiIrcirc!i-?.i5brcirc!i-:oror中盍三笛邯-讦咲供目 h匚T孝ifif: 1 1抽publicpublic EncoJinKrornvefTEncoJinKrornvefT TeftTGbkCon?rr|rereatpGh|r )riveTt)riveTt
33、 0 0retuTHretuTH nwnw thkEncodingConvirtthkEncodingConvirt i i : :因为Conditional注解接收得参数就是一个数组,一次可以传多个Condition,下图所示就表示当Utf8Condition与GbkCondition都返回true时才对该类下得所有方法进行自动装配:- -(Ltf5Can(Ltf5CanbLirnbLir EicodinfflnvprtEicodinfflnvprt cr*acr*at tUtfSConvprUtfSConvprtvjtvjreturnreturn nene L Lt tfSErcodfSE
34、rcodi ingConverTngConverT C C : :ntLir RrodinfflTivprt沪ntflh忒on诵rettirnrettirn n n GhtEiicodingConvertGhtEiicodingConvert - -) )- -Spring Boot还给我们提供了一些很好用得按条件自动装配得类,在org、springframework、boot、autoconfigure、cloud包下面,可以自行研究下,下面演示两个常用得。如ConditionalOnProperty就是与属性配合使用得,ConditionalOnClass与类配合使用,Conditiona
35、lOn Bean与bean配合使用,示例如下publicpublic classclass UserUser ConfConf i-i- f.iralf.iral i i onon当二匸裁射配置.4 斗中档ru-wtrlF-ru-wtrlF- 3 31 1由3 3叵为”朋出-壬三J-J-1 1 oror iruepublicpublic Runniibl-Runniibl- treatcSunfwl-treatcSunfwl- D Dreturnreturn - - J J默认配置文件中加上如下属性运行即可publitpublit classclass SprlnffbootAJSlltAt3
36、CinASprlnffbootAJSlltAt3CinA zEhi7zEhi7ubLubL TcTc staticstatic voidvoid TiainfTiainf StrirEStrirE are?are? i if f Lficujabl#AppIicBtionCcinTSTiTLficujabl#AppIicBtionCcinTSTiT contfxicontfxi = = SprSpr i i nrAaptnrAapt i i c c AtAt i i on.on. rur?rur? (Sen(Sen mbootmboot toptop I I icaticat i iMIA3
37、3 s#nss#ns I IT. . c c asi.asi.arrt?arrt?: : WyatgiLWyatgiL tfUF-tfUF-jrintlnhaiteMt.jrintlnhaiteMt.的血込OfTyjpintOfTyjpint仙iieCcimrFr.iieCcimrFr.CIMSH :SysTiJLSysTiJL iHJf.iHJf. pnpn litlit 1 1 n n ( (ContContSztSzt. .eeleel&e&eILILMTMT沖e e ( (Runnflhle.Runnflhle.c cJ Jassass I I) ):I ICOCLTr
38、COCLTr工三clijSclijS百k k J J -II - -=j U 再如publpubl icicU U - - rCrC onon ftft iptriptr a.ra.r i i onon.零aB5Tir&aB5Tir&耳号曲i i;- - ir-i-ireiir-i-ireirunnable,runnable, enable*,enable*, haha vine.vine. ValueValue = = true*.true*. JoatchifidissinEJoatchifidissinE = = true)true)public RiuiTLablF c
39、reatERunxiab1 1e(Jreturnreturn )=)=:再如publicpublic clajsclajsY/CQUILijition.ijition.= = rujanable.rujanable. enabledenabled na-inValuena-inValue = = *lrue*-*lrue*- matchlfliissinsmatchlfliissins = = truetrue publicpublic Rum.Rum.圧i】i icreAriEjnrLftcreAriEjnrLft:leCileCireturnreturn-.H 4-7._.d 1 _ I-
40、jdia1 1OtCZ HZ z(匚2出clasl Ipublicpublic EurvablcEurvablc1 11 1returnreturn 一publicpublic c c】AAAA CanRunnahlCanRunnahl配握1 1 -.-.黑沁F F; ApAp : 1111二H H二finitefinite classclass SDTiSDTi:iebeitApLi-MticciAssibliebeitApLi-MticciAssiblHiblicHiblic ritnticritntic voidvoid X4X4:nIStripy_nIStripy_CoriifCori
41、if i i oroblrAjjploroblrAjjpl ic#iic#i ioio玄创i icrxlcrxl c c宕葢t t - - priiij.pplicAtpriiij.pplicAt s sOQ.inin豪幻ETWD1 1icicststi i时3=rnh3=rnhIv.Iv. d dqss.qss.监;i i.SystEASystEA uLuL pT3iitpT3iit InIn社匸QuiuHt.QuiuHt. jECSgAnjECSgAn OfTOfT: p=p= * * ELicodingfaiuELicodingfaiug 二、clasclasl l J J . .Sys
42、tED.SystED.outoutprintprint InIn tconteit.tconteit. JtBeansOfTj-peJtBeansOfTj-pe * * RunrabRunrab 1 1 e.e. c c I I ass)ass)、:I Inn uaeuaefl If.mid :广小:庐uutr时述沁卜&丹咗-II - -=j U 再如两个runnable已全部加载tLtL环f f*屮軋“h h i i弭.IrKIrK氓JZJZ . . J,ifJ,if i iItIt I I .Confffr(FiConfffr class)class) publpubl LcLcB
43、iLnuAbl#BiLnuAbl# cr*tat?BedrSunriablecr*tat ;Spring boot实现异步处理vL二iijmnApublicpublic classclass J J卿i i硒IwEtsIwEts PunrifibLiPunrifibLin nptihJieptihJie vftidvftid runOrunOtryf&Tf&T lintlint丄 Ai i iO.iO. I IS SI I-?-?StSt , ,printprint ,n,n : :i i J JT T血JnJn5mn5mn加IsIs:电旳i imlch Except ton
44、e t.t. pipi izitStackLi-iiceizitStackLi-iice H H ; ;二盲近二头L L恥呂栋Uifi.Uifi.;i:i: ngBocngBoc tAppJtAppJ1心.仔叫Ipublicpublic cAcA SprirgbMtJsfpAppSprirgbMtJsfpAppIpublicpublic KtiitirKtiitir voidvoid ntainifStrirjntainifStrirjJ J aT(saT(sConfConf ;.,0;.,0 ATeibleATeible AtipAtip beatbeat ionCionC onioni e
45、-te-t contestcontest = = iuriceAuIication.iuriceAuIication.CurineCurine booboo tjeeato.tjeeato. class,class, aras?aras?: :$y$y s s t t *m.*m. nur.nur. printprint liltliltt t;coniconi extext .EetEeaiAJeep.EetEeaiAJeep.class)class) - - rimrim CC- -Evatettt.Evatettt.cutcut、pTintlntpTintlnt”- *J*J ; ;co
46、jilext.cojilext. close-close- : :Spring boot自动装配没有加注解得beanpublicpublic classclass Rol#Rol#publicpublic clastclastEarConfiEarConfi削祉i i卯publicpublic R.-FBbWR.-FBbW cjeatefoinfiable.!cjeatefoinfiable.!ivtiunivtiun心-:ililr r-:.-mibmib I I icic RcRc二nabltnablt -r-r realreal fRuFinable?(fRuFinable?( j jr
47、eturnreturnHI-r (Vat:. clais,clais, Hoit-clasi, Ike:饰nf i i gutgut atat ion. c I asM; Hcmfrliccmfrlic classclass LiLi::ZLnJ3DotUzr:ZLnJ3DotUzr 15C515C5npublpubl jeje staticstatic VoidVoid|嘛诋55厲:fwfw CcKiflgLirabiifApptlCfltlanJContrflCcKiflgLirabiifApptlCfltlanJContrfl canlextcanlext - - SprLrgApplS
48、prLrgAppl LtLt克LIOJI.伽()4 4盘eboOLltfrApp.eboOLltfrApp.上lala =.=. ftrgslftrgsl : :cnjcnjr r LirLir imimInIn( ( CottexTCottexT _ _ fifian11anfT/pc(EtknunbIrlBron:XfT/pc(EtknunbIc.c.CIBSH门:ccwireit.ccwireit. c cLOSE0 0Sprin gboot事件监听流程:1.自定义事件,一般就是继承ApplicationEvent抽象类;2.定义事件监听器,有多种实现方式,并且对同一个事件可创建多个监听
49、器SUpFrSUpFr I I三门二!匚e e I I 3.发布事件。实现1:publicpublic cla&scla&s MvEeritMvEerit xtertdaxtertda AppApp 1 1 icationEventicationEventprivateprivate staiticstaitic finalfinal langlangsrilVGSsiani/lDsrilVGSsiani/lD - -ILIL: :publicpublic MyEvnt(ObjectMyEvnt(Object source)source) upup r r source)sou
50、rce); ;AuplAupl ifif atat iaiiLiaiiL iilflueriilfluer -MiEvsnl-MiEvsnlpublicpublic *old*old citMjycitMjy 1 1 icAiicAi iu:eniiu:eni sM.sM. EventEvent apyLicdUociEweniapyLicdUociEweni i iS S;. . .sri.-ro.sri.-ro.wit.wit.prpr i i nrnrInIn ) i . dos- I:),实现2:iHibliHibl i i c cMyEefitMyEefit cAlcndscAlcn
51、ds iipiip l l icAticAt lOnEvemlOnEvemprivateprivate staticstatic finalfinal辰*sisi適农王D D = =1 1匚.publicpublicEventObjtcventObjtct tSDUI-CVJ JC&UtFJCt.C&UtFJCt.exex怯工t.t.publicpublic classclass UyLislefcerUyLislefcer ivLeivLe entsents tptp 11cationL11cationLi i; ;t tenerL-enenerL-ent t publicp
52、ublic voidvoid otiAptlicatLGotiAptlicatLG:iE;iE; entent (JCEvtiit(JCEvtiit apylapyl亠catcat丄3 3:iZieutiZieut* * * * applappl idatioiiEvent.idatioiiEvent. getfgetf LaSaLaSa . getEiliEgetEiliE 1 +* 片岌JM业勞越轲*:PubLPubL icic classclass EventAppEventApppublicpublic 5tMi5tMi voidvoid iiAiniStriTKiiAiniStriT
53、K匚contesTcontesT = = 5j)ring.5j)ring.钿plication,plication, firjMEYPKtfirjMEYPKtA App,pp, claas,claas,rgilrgilcoHexl.coHexl. iiiblishEiiiblishE erJerJ (nc(nc W/Even*W/Even* fwfw ObjecHObjecH )j.i.)j.i. centcent ext-ext- dostdost (H(H: :实现3:publicpublic iJiJ片匚s s MyEvifiiMyEvifii cAlrndscAlrnds icaric
54、ar lOfiEvenilOfiEveniprivateprivate staticstatic finalfinal IcnIcn尺serialcwcw CZPCZPpublicpublic EventObjectEventObject souircelsouircelsupprsuppr I I EdurEdur匚宁I I - -publicpublic c c J J assass M;,rLzEtenerM;,rLzEtenerpublicpublic voidvoid onAjnonAjn 1 1 iciticriciticr v v t t HvEvcntHvEvcnt appli
55、estinnZvappliestinnZv上z:t.z:t.i iSysteii.Systeii. etpt.etpt. priotLni4tpriotLni4t (k*(k* + + appliMtiorEvent.appliMtiorEvent. gt-tflasO,gt-tflasO, t-tXainet-tXaine ()()亠片 則业备罡琳I:pubpub lielie clcl且asas E-ntApE-ntAp p ppublpubl LcLc staticstatic voidvoid BairiiBairii StrincE?StrincE? nflnfl: I IConfC
56、onf 1 1 ELirableApplietionContsHtELirableApplietionContsHt contextcontext = = SrinEADplSrinEADpl icic且ticitici:i.i. rrr.rrHrrr.rrH EvertEvert App.App. class,class, ares?ares?- - c-onteJtt.c-onteJtt.p-ablishEvttLtp-ablishEvttLt newnew W W: EventEvent (new(new ObjectObject HUHU *.*.contextscontexts cl
57、oseclose IUIU: :ftrs.51ConfiELtrabIConfiELtrabI ApplAppl icftticniContexticftticniContext具体实例(用户注册,插入数据库并邮件通知):publpubl ifif clstssclstss VserrorTi-oVserrorTi-o le?le? f fprivateprivate tserSer-icetserSer-ice uswrService:uswrService:- - I I 1. IVftlurVftlur - - / lefclilefclinl.rtinl.rtipublicpublic
58、itrinitrin regiregi sterster (Lser(Lser useruserrrturnrrturn &uctr6&uctr6& &publicpublic classclass UstrServic?UstrServic?占pplicncionfonipplicncionfoni色XTXT context.context.publicpublic vaidvaid register(Lregister(L frfr tjsertjser&5&5倨3?3?仁讥切i i:hEhE呻MnewMnew UwrFUwrF媲氐的t t
59、* * 2525 - - thithi昴ILI打publpubl LcLc cldEHcldEH CaeiEegisterEvenlCaeiEegisterEvenl eAtendeAtend ApsLicaApsLica 1 1 i ionEvPionEvPi:t tprivateprivate LierLier ustrr,ustrr,nihlicnihlicIZTgp-Usrgp-Usr(J(Jreturnreturn useruser : :publicpublic UserHeeiEterEvenlUserHeeiEterEvenl (Object(Object source,sou
60、rce,LSTuseuse:-)-)superif50-.irc*superif50-.irc* I I : : this,this, useruser = = user;user;publpubl icic clflssclflss lrRp;ilrRp;iPPTLIETET灯prprLsTe:e_LsTe:e_publpubl icic VOVO d d reg:5reg:51 1eriTserKejeriTserKeji isisiPTTIvpntvpnt eventevent j j聞-TpnT.TpnT.匚EPWSystem.System. oi/oi/ . . printlnfprintlnfHJJHJJ * * 1/1/ - - user.user. gelNfliae)gelNfliae) + + JJ fl.JjfijJcfl.JjfijJc功:publicpublicKegisteLEniai
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 《教育型非营利组织》课件
- 2025届安徽省淮南一中等四校重点中学高考适应性考试数学试卷含解析
- 江西省抚州市临川区二中2025届高考冲刺英语模拟试题含解析
- 2025届新疆阿克苏市农一师中学高三适应性调研考试语文试题含解析
- 2025届安徽省合肥市高升学校高考英语必刷试卷含解析
- 《solidworks 机械设计实例教程》 课件 任务10.2 阀体工程图的设计
- 山东省日照实验高级中学2025届高三下学期第六次检测语文试卷含解析
- 《solidworks 机械设计实例教程》 课件 任务5.2 套筒的设计
- 北京2025届高考英语五模试卷含解析
- 湖北省恩施州三校联盟2025届高三最后一卷语文试卷含解析
- 苏教版高中化学必修第一册专题5微观结构与物质的多样性第二单元微粒之间的相互作用力课件
- 汽车维修投标书服务方案(2篇)
- GJB9001C-2017标准介绍及不符合项案例分析试题与答案
- 顺丰快递合作协议书
- 汽车故障诊断技术:汽车底盘故障诊断与排除
- 中医学概论 知到智慧树网课答案
- (高清版)JTGT 3364-02-2019 公路钢桥面铺装设计与施工技术规范
- 光谱分析培训总结
- 传染病护理学案例分析报告总结
- JT-T-215-1995水下胶粘剂技术要求和试验方法
- MOOC 医学基础-武汉理工大学 中国大学慕课答案
评论
0/150
提交评论