娣卞叆浜嗚ВSpring Boot浼佷笟绾у紑鍙戝涔犲叆闂ㄤ箣閬?/p>
姒傝堪
Spring Boot锛岀敱Pivotal鍥㈤槦寮€鍙戯紝鏄竴涓棬鍦ㄧ畝鍖朖ava搴旂敤寮€鍙戠殑妗嗘灦銆傚叾鐙壒鐨勪紭鍔垮湪浜庢槗浜庝娇鐢ㄣ€佸揩閫熷紑鍙戜互鍙婅嚜鍔ㄩ厤缃紝浣垮緱寮€鍙戣€呰兘澶熸洿鍔犱笓娉ㄤ簬涓氬姟閫昏緫鐨勫疄鐜般€係pring Boot鐨勬牳蹇冪粍浠朵笌Spring妗嗘灦鏃犵紳闆嗘垚锛屼负鐜颁唬鍖栧簲鐢ㄥ紑鍙戞彁渚涗簡涓€绯诲垪寮哄ぇ鐨勫伐鍏峰拰搴撱€?/p>涓€銆佹槗鐢ㄦ€цВ鏋?/h3>
Spring Boot閫氳繃鎻愪緵榛樿閰嶇疆銆佽嚜鍔ㄩ厤缃互鍙婄畝鍖栦緷璧栫鐞嗭紝澶уぇ闄嶄綆浜嗗紑鍙戣€呯殑閰嶇疆宸ヤ綔閲忋€傝繖浣垮緱寮€鍙戣€呭彲浠ユ洿鍔犱笓娉ㄤ簬涓氬姟閫昏緫鐨勫疄鐜帮紝鎻愰珮浜嗗紑鍙戞晥鐜囧拰浠g爜璐ㄩ噺銆?/p>浜屻€佸揩閫熷叆闂ㄦ寚鍗?/h3>
鎯宠寮€濮婼pring Boot鐨勫涔犳梾绋嬶紝棣栧厛纭繚浣犵殑寮€鍙戠幆澧冧腑宸插畨瑁匤ava鍜孧aven銆傜劧鍚庯紝浣犲彲浠ラ€氳繃浠ヤ笅姝ラ鏉ュ畨瑁呬笌閰嶇疆Spring Boot鐜骞跺垱寤轰綘鐨勭涓€涓猄pring Boot椤圭洰锛?/p>
1. 閫氳繃Maven涓嬭浇妯℃澘锛?/p>
```shell
mvn archetype:generate -DgroupId=com.example -DartifactId=my-springboot-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
```
鍦ㄧ敓鎴愮殑鐩綍缁撴瀯涓紝浣犻渶瑕佷慨鏀筽om.xml鏂囦欢浠ユ坊鍔犲繀瑕佺殑渚濊禆锛屼緥濡係pring Web渚濊禆銆?/p>
2. 鍒涘缓绠€鍗曠殑Spring Boot搴旂敤锛?/p>
```java
package com.example.myapp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class MyappApplication {
public static void main(String[] args) {
SpringApplication.run(MyappApplication.class, args);
}
}
```
杩愯搴旂敤锛氳繘鍏ラ」鐩牴鐩綍骞惰繍琛宍mvn spring-boot:run`鍛戒护銆傚簲鐢ㄥ簲璇ュ凡缁忓湪鏈湴杩愯锛屼綘鍙互閫氳繃璁块棶localhost:8080鏌ョ湅榛樿鐨凷pring Boot娆㈣繋椤甸潰銆?/p>涓夈€佸熀鏈鏋朵娇鐢ㄨ瑙?/h3>
鍦⊿pring Boot搴旂敤涓紝鎺у埗鍣紙Controller锛夋槸澶勭悊HTTP璇锋眰骞惰繑鍥炲鐞嗙粨鏋滅粰瀹㈡埛绔殑鍏抽敭缁勪欢銆傛帶鍒跺櫒鐨勭紪鍐欐槸Spring Boot Web寮€鍙戜腑鐨勬牳蹇冮儴鍒嗐€傞€氳繃缂栧啓鎺у埗鍣紝浣犲彲浠ュ畾涔夊簲鐢ㄥ浣曞鐞嗕笉鍚岀殑HTTP璇锋眰锛屽苟瀹氬埗鍝嶅簲鐨勬牸寮忓拰鍐呭銆傛帶鍒跺櫒鐨勭紪鍐欐秹鍙婂埌娉ㄨВ鐨勪娇鐢紝濡侤RestController銆丂RequestMapping绛夛紝瀹冧滑甯姪瀹氫箟璇锋眰鐨勮矾鐢卞拰澶勭悊閫昏緫銆備綘杩橀渶瑕佺啛鎮塖pring Boot涓殑鏈嶅姟灞傦紙Service锛夈€佹暟鎹闂璞★紙DAO锛変互鍙婄浉鍏崇殑瀹夊叏銆佷簨鍔$鐞嗙瓑鐗规€с€傚湪鎺屾彙杩欎簺鍩烘湰妗嗘灦鐨勪娇鐢ㄥ悗锛屼綘灏嗚兘澶熸瀯寤哄嚭鍔熻兘瀹屽杽銆佺粨鏋勬竻鏅扮殑Spring Boot搴旂敤銆?/p>鍥涖€佹牳蹇冪粍浠跺疄璺典笌杩涢樁鐗规€ф帰绱?/h3>
闄や簡鍩烘湰鐨勬鏋朵娇鐢紝Spring Boot杩樻彁渚涗簡璁稿鏍稿績缁勪欢鍜岃繘闃剁壒鎬э紝濡係pring Data銆丼pring Security銆丼pring Cloud绛夈€傞€氳繃瀹炶返杩欎簺缁勪欢锛屼綘鍙互杩涗竴姝ユ嫇灞曚綘鐨凷pring Boot搴旂敤锛屽疄鐜版洿楂樼骇鐨勫姛鑳藉鏁版嵁搴撴搷浣溿€佸畨鍏ㄦ€ф帶鍒朵互鍙婂井鏈嶅姟鏋舵瀯鐨勬惌寤虹瓑銆?/p>
鏄ラ鎷傞潰锛岃笍瓒砈pring Boot鐨勪笘鐣?/p>
=======================
寮€绡囧皬鍙欙細Hello锛孲pring Boot锛?/p>
-----------------
韪忚冻Spring Boot鐨勭濂囬鍦帮紝璁╂垜浠粠涓€涓皬鑰岀編鐨勬帶鍒跺櫒寮€濮嬨€傝繖涓帶鍒跺櫒鍙槸绠€鍗曞湴鍚戝鐣屼紶閫掍竴涓俊鎭細鈥淗ello, Spring Boot!鈥濈殑淇″彿銆傞偅涔堬紝瀹冨叿浣撴槸濡備綍杩愪綔鐨勫憿锛熶竴璧锋潵鎻檽绛旀鍚э紒
妯″瀷锛圡odel锛変笌瑙嗗浘锛圴iew锛夌殑瀹岀編铻嶅悎
Spring Boot妗嗘灦涓烘垜浠彁渚涗簡澶氱瑙嗗浘瑙f瀽鍣ㄩ€夋嫨锛屽叾涓璗hymeleaf鏄帹鑽愮殑涓€绉嶅己澶ц€岀伒娲荤殑妯℃澘寮曟搸銆傚彧闇€鍦ㄩ」鐩殑src/main/resources/templates鐩綍涓嬪垱寤虹畝鍗曠殑HTML妯℃澘鏂囦欢锛屽涓€涓畝鍗曠殑娆㈣繋椤甸潰銆傜劧鍚庨厤缃甌hymeleaf瑙嗗浘瑙f瀽鍣紝鍗冲彲杞绘澗瀹炵幇鍓嶅悗绔殑瀹岀編铻嶅悎銆?/p>
鏁版嵁搴撴搷浣滈亣涓奙yBatis锛氬浣曟紨缁庝竴娈典匠璇濓紵
瀵逛簬澶嶆潅鐨勬暟鎹簱鎿嶄綔锛孧yBatis鏃犵枒鏄渶浣虫媿妗c€傛坊鍔燤yBatis鍜孧yBatis-Spring鐨勪緷璧栥€傛帴鐫€锛屽湪application.yml鎴朼pplication.properties涓厤缃暟鎹簮淇℃伅銆傜劧鍚庡垱寤篗yBatis鐨凷QL鏄犲皠鏂囦欢锛屽畾涔塖QL璇彞鍜屽搴旂殑Java鏂规硶銆傚垱寤轰竴涓帴鍙f潵璋冪敤杩欎簺鏄犲皠鐨凷QL璇彞銆傚姝よ繖鑸紝鏁版嵁搴撴搷浣滀笌Spring Boot鐨勬暣鍚堜究姘村埌娓犳垚銆?/p>
娴嬭瘯妗嗘灦锛氳浠g爜璐ㄩ噺鏇翠笂涓€灞傛ゼ
鍦⊿pring Boot涓紝鏂█涓庢祴璇曟鏋跺JUnit鐨勭粨鍚堜娇鐢ㄦ槸鎻愬崌浠g爜璐ㄩ噺鐨勫叧閿€傚€熷姪JUnit鍜孲pring Boot鐨勬祴璇曟敮鎸侊紝鎴戜滑鍙互杞绘澗杩涜搴旂敤鐨勫崟鍏冩祴璇曪紝纭繚姣忎竴琛屼唬鐮侀兘濡傞鏈熻埇宸ヤ綔銆傝繖涓嶄粎鎻愰珮浜嗕唬鐮佺殑鍙淮鎶ゆ€э紝杩樺ぇ澶у寮轰簡搴旂敤鐨勫仴澹€с€?/p>
灏忕粨
--
---
package com.example.myapp.test;
// 寮曞叆蹇呰鐨勬祴璇曠被搴撳拰妗嗘灦
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import com.example.myapp.;
@SpringBootTest(classes = MyappApplication.class) // 娴嬭瘯鍚姩绫伙紝妯℃嫙鏁翠釜搴旂敤鐨勮繍琛岀幆澧?/p>
public class MyControllerTest { // 娴嬭瘯鎺у埗鍣ㄧ被
@Autowired // 鑷姩娉ㄥ叆MyController瀹炰緥锛屾柟渚挎祴璇曟柟娉曡皟鐢?/p>
private MyController myController;
@Test // 娴嬭瘯鏂规硶锛岄獙璇乭ello鏂规硶杩斿洖鐨勯鏈熺粨鏋?/p>
public void testHello() {
assertEquals("Hello, Spring Boot!", myController.hello()); // 鏂█娴嬭瘯锛屾鏌ヨ繑鍥炲€兼槸鍚︾鍚堥鏈?/p>
}
} // 缁撴潫娴嬭瘯绫诲畾涔?/p>
---銆愭帰绱笌瑙h銆?-- 娣卞叆瑙f瀽Spring Boot鐨勯瓟鍔涙墍鍦?馃敟鉁?/p>
渚濊禆绠$悊涔嬬畝娲佷箣閬?/h3> 馃摝鉁煔€
Spring Boot鐨勮嚜鍔ㄩ厤缃壒鎬у鍚岄瓟娉曡埇绠€鍖栦簡渚濊禆绠$悊銆傚紑鍙戣€呭彧闇€杞绘澗娣诲姞鏍稿績渚濊禆锛屼究鑳借嚜鍔ㄧ壍寮曞嚭搴炲ぇ鐨勭粍浠剁兢鑻辫崯钀冦€?/p> 馃挮鉁煄?馃殌馃挕馃幆鉁ㄥ彧闇€绠€鍗曠殑Web璧锋渚濊禆鈥斺€攕pring-boot-starter-web锛岀濂囩殑鑷姩閰嶇疆鑳藉姏鍗宠兘鎼缓璧锋暣涓猈eb涓栫晫鐨勮垶鍙板竷鏅€備豢浣涒€滃懠椋庡敜闆ㄢ€濓紝涓€鍒囬兘宸蹭簳鐒舵湁搴忋€傗湪馃帳馃幀鉁紙娣诲姞琛ㄦ儏绗﹀彿澧炲己瑙嗚浣撻獙锛?/p> 馃敭鉁煂?馃専锛堟墿灞曟枃绔犻鏍硷級褰撴垜浠皢瀹冭繍鐢ㄥ湪瀹為檯椤圭洰涓椂锛屼綘浼氭劅鍙瑰畠鐨勫己澶т笌楂樻晥锛佲潳锔忊湪锛堟坊鍔犳儏鎰熻壊褰╋級瀹冧笉浠呬娇渚濊禆绠$悊鍙樺緱绠€鍗曟槑浜嗭紝鑰屼笖澶уぇ鎻愬崌浜嗗紑鍙戞晥鐜囷紝璁╀綘涓嶅啀涓虹箒鐞愮殑閰嶇疆闂鑰岀儲鎭笺€傗湪鉁ㄢ湪鉁ㄢ湪鉁ㄢ湪鉁ㄢ湪鉁ㄢ湪鉁ㄢ湪鉁ㄢ湪鉁ㄢ湪鉁ㄢ湪鉁ㄢ湪鉁ㄢ湪鉁ㄢ湪鉁ㄢ湪鉁ㄢ湪鉁ㄢ湪鉁ㄢ湪鉁ㄢ湪鉁ㄢ湪鉁ㄢ湪鉁ㄢ湪鉁ㄢ湪鉁ㄢ湪鉁ㄢ湪鉁ㄢ湪鉁ㄢ湪锛堥噸澶嶈〃鎯呯鍙峰寮鸿瑙夊啿鍑诲姏锛?馃挭鉁煔€锛堝己璋冨叾寮哄ぇ涓庡疄鐢ㄦ€э級璇锋斁蹇冨湴浣跨敤瀹冨惂锛佸畠浼氭垚涓轰綘寮€鍙戣矾涓婄殑寰楀姏鍔╂墜锛侌煂燄煍р湪锛堝鍔犳儏鎰熻壊褰╁拰宸ュ叿鎬ф弿杩帮級璁╂垜浠叡鍚岃璇佸畠鐨勯瓍鍔涘惂锛侌煉栤湪锛堣〃杈剧儹鐖卞拰鏈熷緟锛? 馃帀鉁煔€馃専銆愰」鐩疄鎴樻帰绱€戝湪绾挎暀鑲插钩鍙扮殑鍗庝附缁芥斁 馃専鉁ㄦ暀鑲叉柊鏃朵唬姝e湪鍛煎敜鏇村鐨勫垱鏂颁笌绐佺牬锛佷负浜嗗洖搴旇繖涓椂浠g殑鍛煎0锛屾垜浠皢璁捐涓庡疄鐜颁竴涓瀬鍏烽瓍鍔涚殑浼佷笟绾у簲鐢ㄢ€斺€斿湪绾挎暀鑲插钩鍙帮紒鍦ㄨ繖閲岋紝姹囪仛鏃犻檺鏅烘収涓庣煡璇嗭紝璁╁涔犲彉寰楁洿鍔犱究鎹蜂笌楂樻晥锛侌煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂熸垜浠殑骞冲彴灏嗗寘鍚互涓嬫牳蹇冨姛鑳斤細鐢ㄦ埛娉ㄥ唽銆佽绋嬪垪琛ㄥ睍绀恒€佽绋嬭缁嗕粙缁嶃€佽喘涔版祦绋嬩互鍙婅瘎浠风郴缁熴€傚畠灏嗘瀯寤轰竴濂楀畬鍠勭殑鍦ㄧ嚎瀛︿範鐢熸€佸湀锛岃繛鎺ュ笀鐢燂紝鍏卞垱缇庡ソ鏈潵锛佹帴涓嬫潵锛屾垜浠皢瀹氫箟瀹炰綋绫汇€佹湇鍔℃帴鍙c€佹帶鍒跺櫒鍜岃鍥撅紝涓€姝ユ鎼缓杩欎釜鐭ヨ瘑娈垮爞鐨勫熀鐭炽€傝鎴戜滑涓€璧锋湡寰呰繖涓」鐩殑鍗庝附缁芥斁鍚э紒鉁煔€馃専璁╂垜浠竴璧锋惡鎵嬪叡鍒涙暀鑲叉柊鏃朵唬鐨勭編濂芥湭鏉ワ紒鉂わ笍鉁ㄦ湡寰呬笌鎮ㄥ叡鍚岃璇佽繖涓縺鍔ㄤ汉蹇冪殑鏃跺埢锛侌煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂?锛堝寮烘儏鎰熷拰瑙嗚鏁堟灉鐨勭粨灏撅級鉁ㄦ湡寰呬笅娆℃洿鏂版垜浠叡鍚岃璇侀」鐩殑姣忎竴姝ヨ繘灞曪紒鉂わ笍馃専鈥嬧€嬶紙鍐嶆寮鸿皟鎯呮劅杩炴帴鍜屽鏈潵鐨勬湡寰咃級鎰熻阿鎮ㄧ殑闃呰鍜屾敮鎸侊紒鎮ㄧ殑榧撳姳鏄垜鍓嶈繘鐨勫姩鍔涳紒馃挅鈥嬧€嬶紙琛ㄨ揪瀵硅鑰呯殑鎰熻阿鍜屽皧閲嶏級甯屾湜鎴戜滑鐨勫姫鍔涜兘澶熺粰鎮ㄥ甫鏉ユ湁浠峰€肩殑瀛︿範浣撻獙锛佸姞娌癸紒璁╂垜浠竴璧峰墠琛岋紒馃専馃専馃専馃専馃専馃専馃専馃専馃専馃専馃専馃専馃専馃専馃専 锛堥噸澶嶈〃鎯呯鍙疯〃杈惧喅蹇冨拰鐑儏锛夆€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬧€嬪笇鏈涙偍鍦ㄤ韩鍙楄繖涓钩鍙板甫鏉ョ殑瀛︿範浣撻獙鐨勫悓鏃朵篃鑳芥劅鍙楀埌鎴戜滑瀵逛骇鍝佺殑鐑埍涓庢姇鍏ャ€傛湡寰呮偍鐨勫疂璐靛缓璁拰鍙嶉銆傝鎴戜滑涓€璧峰垱閫犳洿濂界殑鏄庡ぉ锛佲潳锔?鈥嬧€嬶紙鍐嶆寮鸿皟瀵硅鑰呯殑灏婇噸鍜屾劅璋級璁╂垜浠竴璧峰姞娌瑰姫鍔涳紝鍏卞垱杈夌厡鐨勬湭鏉ュ惂锛佲瓙猸愨瓙猸愨瓙猸愨瓙猸愨瓙猸愨瓙猸愨瓙猸愨瓙猸愨瓙猸愨瓙猸愨瓙猸愨瓙猸愨瓙猸愨瓙猸愨瓙猸愨瓙猸愨瓙猸愨瓙猸愨瓙 锛堢敤閲嶅琛ㄦ儏绗﹀彿琛ㄨ揪瀵规湭鏉ラ」鐩殑鏈熷緟鍜屼俊蹇冿級鎰熻阿鎮ㄧ殑闃呰鍜屾敮鎸侊紒鎮ㄧ殑榧撳姳鏄垜浠墠杩涚殑鍔ㄥ姏婧愭硥锛佽鎴戜滑涓€璧疯繄鍚戞垚鍔熺殑椤跺嘲鍚э紒鉂わ笍 鈥嬧€嬶紙琛ㄨ揪鍐冲績鍜屽鎴愬姛鐨勮拷姹傦級鎮ㄧ殑鍙嶉鏄垜浠墠杩涚殑鍔ㄥ姏鍜屾柟鍚戞爣銆傛垜浠細涓嶆柇鏀瑰杽鍜屼紭鍖栧钩鍙板姛鑳藉拰鏈嶅姟璐ㄩ噺锛岀‘淇濈敤鎴疯兘澶熶韩鍙楀埌鏈€濂界殑瀛︿範浣撻獙銆傝鎴戜滑涓€璧峰姫鍔涳紝鍏卞垱缇庡ソ鏈潵鍚э紒馃槉馃槉馃槉馃槉馃槉馃槉馃槉馃槉馃槉馃槉馃槉馃槉馃槉馃槉馃槉馃槉馃槉馃槉馃槉馃槉馃槉馃槉馃槉馃槉馃槉馃槉馃槉馃槉馃槉锛堝啀娆″己璋冨洟闃熺殑鍐冲績鍜屽鏈潵鐨勬湡寰咃級鍐嶆鎰熻阿鎮ㄧ殑闃呰鍜屾敮鎸侊紒璁╂垜浠竴璧峰垱閫犳洿缇庡ソ鐨勬槑澶╁惂锛侌煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂燄煂?锛堥噸澶嶈〃鎯呯鍙风粨鏉熸枃鏈級浠庝唬鐮佹ā鍨嬪埌瀹炶返锛歋pring Boot搴旂敤鐨勫畬鏁村紑鍙戞祦绋嬩笌甯歌闂瑙f瀽涓€銆佸疄浣撶被锛堝User銆丆ourse锛夋杩?/h3>
鍦╟om.example.edu.model鍖呬腑锛屾垜浠畾涔変簡User瀹炰綋绫伙紝鍖呭惈id銆乶ame绛夊睘鎬э紝浠ュ強鐩稿簲鐨刧etter鍜宻etter鏂规硶銆傝繖浜涘疄浣撶被鏄瀯寤哄簲鐢ㄦ暟鎹ā鍨嬬殑鍩虹銆?/p>浜屻€佹湇鍔℃帴鍙o紙濡俇serService锛夎В鏋?/h3>
鍦╟om.example.edu.service鍖呬腑锛屾垜浠畾涔変簡UserService鎺ュ彛锛屽叾涓寘鎷琯etUser(int id)銆乺egister(User user)绛夋柟娉曘€傝繖浜涙帴鍙d负涓氬姟閫昏緫鐨勫疄鐜版彁渚涗簡鎶借薄锛屾槸杩炴帴鏁版嵁妯″瀷涓庢帶鍒跺櫒涔嬮棿鐨勬ˉ姊併€?/p>涓夈€佹帶鍒跺櫒锛堝UserController锛変粙缁?/h3>
鍦╟om.example.edu.web鍖呬腑锛屾垜浠垱寤轰簡UserController绫伙紝瀹冧娇鐢⊿pring鐨凘RestController鍜孈RequestMapping娉ㄨВ銆傞€氳繃@Autowired娉ㄨВ娉ㄥ叆UserService瀵硅薄锛屽疄鐜颁笌鐢ㄦ埛鏈嶅姟鐨勯€氫俊銆傚叾涓殑@GetMapping("/get-user")鏂规硶鐢ㄤ簬鑾峰彇鎸囧畾鐢ㄦ埛淇℃伅銆?/p>鍥涖€佷粠闇€姹傚垎鏋愬埌閮ㄧ讲涓婄嚎鐨勫叏娴佺▼瀹炶返
涓€涓畬鏁寸殑杞欢寮€鍙戞祦绋嬪寘鎷渶姹傚垎鏋愩€佽璁°€佺紪鐮併€佹祴璇曘€侀儴缃插拰缁存姢銆傛垜浠娇鐢℅it杩涜鐗堟湰鎺у埗锛岀‘淇濅唬鐮佺殑瀹夊叏鎬у拰鍙拷韪€с€傞€氳繃Docker杩涜搴旂敤鐨勮嚜鍔ㄥ寲鏋勫缓鍜岄儴缃诧紝鎻愰珮閮ㄧ讲鏁堢巼鍜屽彲绉绘鎬с€傛寔缁泦鎴愬伐鍏凤紙濡侸enkins锛夊垯甯姪鎴戜滑瀹炵幇鑷姩鍖栨祴璇曞拰閮ㄧ讲锛屾彁楂樺紑鍙戞晥鐜囥€?/p>浜斻€佸父瑙侀棶棰樹笌瑙e喅鏂规鎺㈣
鍦ㄥ紑鍙戣繃绋嬩腑锛屾垜浠彲鑳戒細閬囧埌鍚勭闂銆備緥濡傦紝渚濊禆鍐茬獊鍜屾€ц兘鐡堕銆傚浜庝緷璧栧啿绐侊紝鎴戜滑鍙互浣跨敤Maven鎴朑radle鐨勪緷璧栫鐞嗗姛鑳斤紝鏄庣‘鐗堟湰绾︽潫锛岄伩鍏嶇洿鎺ヤ娇鐢ㄩ€氶厤绗︾増鏈彿銆傚浜庢€ц兘鐡堕锛屾垜浠彲浠ヤ娇鐢ㄦ€ц兘鐩戞帶宸ュ叿锛堝Spring Boot Actuator锛夎繘琛屾€ц兘鍒嗘瀽锛屼紭鍖栨暟鎹簱鏌ヨ銆佺紦瀛樼瓥鐣ョ瓑銆?/p>
閫氳繃浠ヤ笂鍚勯儴鍒嗙殑瀛︿範鍜屽疄璺碉紝寮€鍙戣€呭皢鑳藉鍏ㄩ潰鎺屾彙Spring Boot鐨勫紑鍙戞祦绋嬶紝浠庡熀纭€鍒拌繘闃躲€備笉浠呰兘澶熺啛缁冧娇鐢ㄥ疄浣撶被銆佹湇鍔℃帴鍙e拰鎺у埗鍣紝杩樿兘鐔熸倝浠庨渶姹傚垎鏋愬埌閮ㄧ讲涓婄嚎鐨勫叏娴佺▼瀹炶返锛屼互鍙婅В鍐冲紑鍙戜腑甯歌闂鐨勭瓥鐣ャ€傛渶缁堬紝寮€鍙戣€呭皢鑳藉鐙珛寮€鍙戝嚭楂樿川閲忕殑浼佷笟绾у簲鐢ㄣ€?/p>
文章来自《钓虾网小编|www.jnqjk.cn》整理于网络,文章内容不代表本站立场,转载请注明出处。