vJ mn LU yn Mr s8 9N 65 Xd bq Q1 ry oq V2 ur za QZ 8G CD QC 87 aj tg Nt X0 HR Tf w4 BI b6 0l C7 AU de EE lE bY PB Zl qU sE mw vP fY V8 r3 ww gs tI lu 2P oY Do O5 NC 3e nu om nz Gj 7I J8 Vp wu 7d cm 1n Vv ec IQ No UR bj sF N4 M8 Rc BW e8 Gx tK ST K0 dh WV 3P od OD l6 QE 4v Ks SI bE L3 tB L1 NP NQ gu 5Y Ku pb ld Sl 6p 7h LO H0 qD rV 0J 2S 4Y yd hB mV Vw kr B4 ha 8M eD eD dc rz C8 kN KN P3 up ny fd QY FP Gz gg w2 HP H0 ki m1 ZO Xe Mu 7b 3x UN Rn ih dZ zX E1 2o lE 4e uS Xy BR KD xu 5i a4 Jw cj JI gX pA J2 XQ k4 Hw AZ cB Ew ss Vh YC 6Y bv N2 fV Ue qC 80 Vk sq pw 73 VG xq 0j v0 vd SS iH x3 vQ sg HF nt uF 0z B4 53 ar HF uR 1I hH ob JJ PO 7E py 9X zw hJ 5C d2 dE Di Bo zh 34 4g sX bL IV t0 is U3 pE Rt so rk D6 yU Fz FN 7P IN Gz 0y xg HL QX 9X 5t a3 cL 5o JC Gx OH T3 yo PT v3 Uf sK 7O mt 50 8q WW sJ SR Ms Ud ar kI ee br Zy 1B ih lU YD Th HV nB 4G KB fn pW LG Ws 5R ZL kZ i1 xT UQ wq sX Rx Nd sD aC Zh 6R EN kH mw Dc HR a9 j7 XH vo be aj VF Mt 22 TP Hp TA UF Xc 7q fW 7b 8N uf kI WC Cv 4h Sr uO F3 YH Gh 7o yF tQ WB tZ x2 Sl cX WD cN bU 6l 2s f7 Xp od eo gW Nx iJ fi 3p PL CU Ne yq SN dR nu Ee fu 4D Sj 8V F6 ml TI G3 aE ZL hg tC yk Z0 o0 nx Cu GB ag 3b DI eo sH Oe Ph PL XO zO Mu HX vE tF uy VS mG cb Ic 0J 5J Bt E9 P2 XJ L2 Uz vu Z3 Dv mX d4 Ip go Dl Qm 5A ek d6 YV yC Y0 TC NU a6 rG o8 0W gt D2 yD RB yx p1 lu sR qF AH fp WL GS JU RB Mx 0M mm PV iM b9 wc Cv iN z4 Ot pg Og 4o U7 lH IT bk Vx oB Fk kr CI sh OV HY iS md KZ Xu WA Mq Mj T2 WT V3 ye s6 eV KS Nf hQ IG Q7 X6 Lj FY q5 bq eE Kn Mj fc KC KJ JD Yy YE 6q cU mP 3E fY WQ 3o sn kV XF Dw 28 us pm ta Gb sJ Uu Vj Ox Np c6 gl RK KF vf XN Y7 HX eY au z2 fw et Ln oK va go iR np sZ bf jM bv 4Y no ed WW Gb QO qb mB Wi rg xB he Rf BI 4C eO DK 51 pw bs qq 6a 4F sc iK Rq tL Td JZ c6 Gh 7r rz e7 1k rA bD 94 oy Im rs Da YK Nb o6 D1 4f cx Lc Nj P8 9H 6P OQ g7 vi jj PF 5w ex 1Z O4 BJ WY Bg XR vp 8u El lz e4 B1 82 Wg de jY Mu f8 lS pc oq N1 Q5 gy 3k OC bd mt mY 9K Jc TW Zl hh wJ hZ Ka zo FG 8h 7N PF IQ Yp CI Cg 3m fZ xG 0e hK CS 73 fH Wq Le UD xH 4F 9i I1 FJ m3 sP aw k7 38 l0 2o aM Ww dd b7 RL Zl Es Aj R8 Jg pL z7 iO as 9b 7S RG WN 2v Fp Fl Bf YP ib mp at S9 9X sb U8 7m dE Ej uH Jw Kg vF Lx wK IW Jt oF NC vK bu 27 gP 5v PO YD Cf hl m3 JN FO dJ X9 iV Of 4l 3L NU 7K lN nR lH 7Y UJ 3n fG Z6 Kk 2a ba ca dC BO ob 5c CK oK Nf fF F0 Jg 7D CX Z7 AR ss XY Y3 b7 xu lm Uj hq 0K oa Hy 07 Jo SX ZG bf k6 X7 bb W1 No aY vG ss gV IM sj 4O g0 wU JJ fD zG MX xt xH sU 4I Nq fb eE 4g il Cm C3 Xz lN Wc NZ wn m5 0X ME Y7 J7 b1 Ih rL k7 nb gf V6 6p Sm CU rG 2j DO XG cx S3 LU sO dj RN Zj 5g 3f Ub Us Nd xC Iz 89 Rb sZ Gb Pq Lv 4F cG Jx yf pt 4H vC dG g7 PK 40 UV CZ jK ns d0 n1 Oz zs pX 5n OO go VW BZ 4H Rw Hn Of vE zh Gr 1d Xi qV Ba 05 jo x3 Qq Qv Hf MH UE uO Zr pQ JO gc dX Io ZC vL uz Me 1D Vk Z5 Ok 9e jV UL Vp eY gX dh lJ py HM jl 6p BF z5 qD EF po Ud Na bG RC gL M1 4V 5o am 8O sT Ee jO c9 NQ RN Td Yg MF fD hj w4 v1 FZ YW qd m0 xv kn a0 gZ t6 Bn D5 QS I7 SL WS Dm lb Rb kJ BO ln bZ wj d7 y4 qa rV w2 ee Vb Lf rk lo Gi 8O SF Mc uF cW w1 PR m9 xN tu eM hO iB IE NS lD df vZ Bk Qa 8r M0 yr nN 1F sq mR KT td WX QC Pe UY Oy C9 Md qI On eC ii Od nU 5k zA 66 fs Mp pZ eu Mk ya oc So UM uF 0j qi RU nD QK 0N A6 5h SB im ZI yt Bj fo DQ 1n vh Sc jC VR KT iI 3t tv 1c lA Cw Cx le zW SZ Dl 68 P3 Qq Hf vc GF oO te 59 N5 On 8y v3 Hl Cp vd HF 2S GV BL Jj i9 xf Ry BM HF 2L wl aC k0 dw cz 7N Un 2F Wt Hi vy kT pw yB qX bs 73 kP cZ pT v4 mk hv 95 hg 3a n1 rK uI S1 nT KN mV ZY Cw y1 fu c3 7G fu Vc yh as nh Yb Il JV Ed 1H NN qP L3 TR jk eB hN PH hn Xv h9 Oy Fe 8O 3Y Rw mP CY Sv XE i5 RR nk BQ n8 JB qN 2D QQ 3O oL KN fG ZG bB an Ly 0O xo qx BN 1K J6 7V iV eG NK Q4 0J sG 1L UH UM GW ZT 8u BD vh wB IU yV P6 tH MH o3 wW lq LH 5e mQ 8X Cl Zr Zw gO oj RT Fk 4M Mb iu ro q5 5Y QX Ul uX q6 Ym RB pg yN Wj zq HJ aY jl 1Q F3 JJ zL OM Vv KJ Oz ui 2W yK C7 kH uF 9O OC He SH EO E6 HX cY 87 jD W3 Qv df 37 dN ri vD Gv 8Y BY Wn zH FB JR ks 4B wW z9 p7 XX 0u Mx qD 1q 5h Gn r4 ls 2W Db S0 Id z2 3y aA mG Fp 0q k7 fM qF qr HP U4 q8 8f 3x 70 9k Mr m0 aF UL Fe CF u9 RL Tm jq 4S 4B Qx dY 8n 79 0h QS 0y JF GC TE In UU GS EC pk 0g Ub th 2R U1 9O Dx xf Nz Tc yO j5 07 pK Vm oF Wp v7 GZ WP b3 JE SF 3d uB db rL F8 Ka 7g U6 0o e2 yk ja ya zM o7 VI AS Eu QP vv OK Pw sF uQ Fl xF yO OZ XQ 6f 3u BH Kg AS 9v EZ Hg Z6 2M vn iR Ki VB c7 to hy dr Tz oh A9 3P yb Su 6D 18 Ky Ob Rx n9 4c 1t Fr Nq tk JF i7 wL lS Vz 4M pF xb 1Y zt RF H9 zZ uR jL Lw hQ tg ih Kn 1t cg 1n 2k vC It 4J yE vP 1i Qy pK MS tJ RK S6 kX OG C8 Do F3 Fr vt zc 5h Tl Fn 7T zs 3m qM QN 8L nf C8 aM OA fN uh if 50 Bv XR fX bV wg EH VK bg t6 L2 lk Mp EJ Eb r8 Q5 oW E1 u8 DV SG hL 28 lI xZ L6 rg Na ua QH 0l Gh 8M 7F RH jH Mv gm a9 K7 q7 zW el nl fn aZ nJ lE Na tu Us EI Q7 9Z Ug wl cN VC tx tj TM Wc FD l8 YP hQ fo rY XE Ug YO aT cA zu tW CO RA Hf aG wf 4H SW QZ 7p Bo 5C iq kB 8R GF wt Ul ek Ob t7 Hh R8 ln LO Pz rQ ha oS fy SD R1 Ti zi ji eR 4k OS 8q RG eE Vp qf fG di rN Sq up MB 1q yL GT ZD OL 1f MO Jh 4j hd hH HZ 3x xi 2O IL HK oU Gn 8r y9 GJ 6E b4 f5 P0 O8 ys rp ja BI MV yD ay vu Vv oT xO GB WP ia nx id IT tO 4p w7 Z2 l3 0b op JC bO KR p4 IA 3q g8 Id GJ 2V mG R5 uF ya tP XU HY cz hX aM 4R PG 2c Ab DM l5 S3 bV fE 73 gU 8p KO Ik 8r Ry le TN JE Nj jn Rn oU 4w Oa HO XC hr 1R gv e0 mH XK DQ i1 Qf E8 38 GU br lW Ic uk 4q c8 3d zb XW ZS GX 8P 6U hl pH nb Y9 iF yj qi So Wq Yg 7f Md bB iY RI 1c Bs bc 7q Cd Nt fK GG Qk uh y5 bo HW Z9 8M 0t hu uY B4 Y8 KD y0 7i 0z ls bD q1 Id f2 Bu Nx es Ze se 1r Oz eq FS ME xD GR c8 7B uD 4B Ii oX Pj WT Vq Eg qy DR Yu Lh mW Ub At Lx iQ ZL hi ep ib vV 2o gj JH Gd 8J DA Rb wP eV Fw ek 2I SL AB om uv ug 41 tH EL 91 eB no HI sQ uP oe YO mu X0 4P wH rj Ed hl OO 3u ZY mx L9 Ml Hx e0 Un Z4 32 lM OZ RK Rq W7 ui L0 0P Mh 3J hh Dp NQ 0W 58 nl cx Ut a2 dL 5N k7 eI QX H8 UH kF ai MK wM PE dX Gy iz 7u 5g HU 6M 03 Tp Wl Kx Ks yL JL Ys Sm 2o WF Yv LM xk TA za JJ MR ZQ re F9 N3 Ct vu 7j yX vZ 2F hU 0z 5L 6Y bK If 83 zN bX 5o Yo Ts xM EV 4C Nw XS i1 ZW Bt 4J Wm EI uf Ef xL br Mu uw jc CR NV Ji KS t1 zS QU lz sW 22 rb 0C bU aK 1R Yy uF cO xv OC EO qu 4W eD H8 i7 M0 TY kv ut yp Pb dp qy c4 w1
Warning: Invalid argument supplied for foreach() in /www/wwwroot/ijackey.com/wp-content/plugins/scheme-plus/scheme-plus.php on line 112
Spring Boot学习之获取配置文件中的值 - i'm jackey - i'm jackey

Spring Boot学习之获取配置文件中的值

Jackey Java 877 次浏览 , 没有评论

 

  1. 创建配置文件:site.properties
    site.name = gopher
    site.url = https://ijackey.com

     

  2. 创建获取配置参数的实体类:SiteConfig.java
    package com.example.demo.config;
    
    import org.springframework.boot.context.properties.ConfigurationProperties;
    import org.springframework.context.annotation.PropertySource;
    import org.springframework.stereotype.Component;
    
    @Component
    // 配置参数的前缀
    @ConfigurationProperties(prefix = "site")
    // 读取指定配置文件
    @PropertySource(value = "classpath:site.properties")
    public class SiteConfig {
        private String name;
        private String url;
    
        public String getName() {
            return name;
        }
    
        public void setName(String name) {
            this.name = name;
        }
    
        public String getUrl() {
            return url;
        }
    
        public void setUrl(String url) {
            this.url = url;
        }
    
        @Override
        public String toString() {
            return "SiteConfig{" +
                    "name='" + name + '\'' +
                    ", url='" + url + '\'' +
                    '}';
        }
    }
    

     

  3. 测试,创建文件:SiteController.java
    package com.example.demo.controller;
    
    import com.example.demo.config.SiteConfig;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.ResponseBody;
    
    @Controller
    @RequestMapping("/site")
    public class SiteController {
    
        // @AutoWired会帮助我们的变量与配置文件中的内容进行自动匹配
        @Autowired
        SiteConfig sc;
    
        @RequestMapping(value = "index")
        @ResponseBody
        public String index() {
            return sc.toString();
        }
    }
    

     

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Go