涓€鏂囧甫浣犵帺杞璁℃ā寮忎箣銆岃矗浠婚摼銆?/a>
Posted 灏忛綈鏈綈
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了涓€鏂囧甫浣犵帺杞璁℃ā寮忎箣銆岃矗浠婚摼銆?/a>相关的知识,希望对你有一定的参考价值。
寰俊鎼滅储馃攳銆岀爜鍐滅敯灏忛綈銆嶏紝鍏虫敞杩欎釜鍦ㄧ航绾︾殑绋嬪簭濯涳紝鍥炲銆?1-05銆嶅彲浠ヨ幏鍙栬绠楁満绮鹃€変功绫嶃€佷釜浜哄埛棰樼瑪璁般€佸ぇ鍘傞潰缁忋€侀潰璇曡祫鏂欑瓑璧勬簮锛屼箞涔堝搾锝?/blockquote>鍓嶈█
瀵逛簬宸茬粡宸ヤ綔浜嗙殑灏忎紮浼达紝浣犲簲璇ユ槸瑙佽繃"璐d换閾?杩欑闈㈠悜瀵硅薄鐨勮璁℃ā寮忕殑锛岃繕鍦ㄤ笂瀛︾殑灏忎紮浼翠篃涓嶇敤鐫€鎬ワ紝浣犺繜鏃╀細鎺ヨЕ鍒扮殑銆傛湰鏂囨棬鍦ㄨ灏忕櫧鍚屽鍜屼笉澶啛鎮夎矗浠婚摼鐨勬湅鍙嬭兘澶熻繀閫熷杩欎竴璁捐妯″紡鏈変竴涓ぇ鑷寸殑浜嗚В銆?/p>
鍦ㄦ垜浠殑宸ュ啘涓氱敓浜т腑锛岀粡甯告湁杩欐牱鐨勫満鏅細涓€涓换鍔°€佷簨鍔°€佹祦绋嬬瓑閮介渶瑕佸緢澶氫笉鍚岀殑姝ラ锛屾潵瀹屾垚涓嶅悓鐨勮绠楁垨鑰呮敹闆嗕笉鍚岀殑鏁版嵁銆?/p>
涓轰簡缁存姢涓€涓瘮杈冨鏉傦紝鏈夋椂鐢氳嚦鏄椤哄簭鏁忔劅鐨勪换鍔℃祦绋嬶紝鎴戜滑缁忓父鍦ㄤ唬鐮佺殑缂栧啓鍜岃璁′笂閲囩敤"璐d换閾?璁捐妯″紡銆?/p>
绌剁珶浠€涔堟槸"璐d换閾?鍛紵鍜变滑鐪嬩笅闈㈣繖涓緥瀛愩€?/p>
渚嬪瓙
鍋囪浣犱篃"绌胯秺"鍒颁簡娓呮湞锛屾槸浼氬啓浠g爜鐨勫拰鐝呭拰涓爞锛岀殗涓婇┈涓婅鍗楀贰銆傝浣犵敤浠g爜灏佽骞舵ā鎷燂細"涔鹃殕涓嬫睙鍗? 杩欎欢浜嬨€?/p>
浣犺鎬庝箞瀹夋帓涓囧瞾鐖风殑琛岀▼锛熻鐭ラ亾杩欏彲鏄釜澶у伐绋嬶紝涓棿鍙笉鑳芥湁宸敊锛屼竴鏃﹀嚭浜嗕粈涔堝矓瀛愬彲鏄鎺夎剳琚嬬殑 馃槀
浣嗙殗涓婂張鏄€ф儏涓汉锛岃绋嬪彲鑳界粡甯告洿鏀癸紝鐢氳嚦鍗婅矾灏卞井鏈嶇璁裤€?/p>
鎵€浠ユ垜浠湪浼哄€欑殗涓婁笅姹熷崡鐨勬椂鍊欙紝鏃㈠緱璁╃殗涓婄殑琛岀▼鏈夊簭杩涜锛屽張瑕佸敖閲忛€傚簲鍦d笂鐢变簬涓€鏃跺叴璧疯€屽彲鑳藉仛鍑虹殑鍙樺寲銆?/p>
鎬庝箞璁捐鍛紵濡傛灉鎶婄殗涓婄殑琛岀▼閮藉啓鍦ㄤ竴璧锋墽琛岋紝鏈変袱涓笉濂界殑鍦版柟锛?/p>
- 琛岀▼澶锛岃€屼笖鍏ㄩ兘浜嬪叧閲嶅ぇ锛岃繖涔堣繙鐨勮矾锛屽叏閮借浣犱竴涓汉鎵撶悊锛屽摢閲屼竴涓嶆敞鎰忓嚭浜嗕贡瀛愶紝鑴戣灏辫鎼锛?/li>
- 琛岀▼澶氾紝鎵€浠ュ鏀硅捣鏉ュお楹荤儲锛屼竴鏃︽湁鏀瑰姩鍦d笂鐨勮绋嬭〃瀹规槗涔便€傛瘯绔熻绋嬪啓鍦ㄤ竴璧凤紝濂戒技
涓€鍫嗕贡楹伙紝鏉$悊涓嶆竻銆?/li>鎵€浠ラ棶棰樻潵鍟︼紝鍜屽ぇ浜烘偍鍙€庝箞鎺掑湥涓婄殑琛岀▼鍛紵
鍜屽ぇ浜鸿帿鎬ワ紝鐪嬬湅鍦板浘鎴戜滑灏辩煡閬擄紝涔鹃殕浠庡寳浜埌鏉窞瑕侀『搴忕粡杩囩洿闅躲€佸北涓溿€佹睙鑻忋€佹禉姹熷洓鐪侊紙鍩烘湰灏辨槸鐜板湪浜勃楂橀搧鐨勮矾瀛愶級:
杩欐牱鍜屽ぇ浜哄氨鍙互鎸夌渷鎶婁换鍔″ぇ鑷村垝鍒嗕负鍥涗釜閮ㄥ垎锛岃矗鎴愬洓鐪佺殑瀹樺憳浠垎鎷呰繖涓€涓ぇ宸ョ▼锛屾妸浠栦滑搴斿敖鐨勭殑璐d换杩炴垚涓€涓湁搴忕殑閾炬潯锛岀劧鍚庝緷娆¤浠栦滑鎵ц浼哄€欑殗涓婄殑浠诲姟銆?/p>
杩欐牱涓€鏉ヨВ鍐充簡琛岀▼杩囦簬涓板瘜锛屽拰澶т汉涓€涓汉瀹夋帓涓嶈繃鏉ョ殑闂锛屼簩鏉ヤ繚璇佷簡鍚勪釜姝ラ鐨勭伒娲诲畨鎺掞紙鍚庨潰鐨勪緥瀛愯锛夛紝涓夋潵鍝竴姝ュ嚭浜嗛棶棰樿繕渚夸簬闂矗锛堢敥閿咃紝鍚﹀垯鍏ㄦ槸鑷繁鐨勯敊锛夈€?/p>
濂戒簡锛岃浜嗚繖涔堝锛岀幇鍦ㄥ垏鍏ユ妧鏈眰闈€?/p>
璁捐
Step1:
棣栧厛鎬荤粨涓€涓嬫垜浠墍鐮旂┒鐨勯棶棰樹腑鐨勫悕璇嶏紝鏉ョ‘瀹氬ぇ姒傞渶瑕佸摢浜涚被锛?/p>
- 鐨囧笣锛堜咕闅嗭級
- 琛岀▼鐨勭鐞嗚€咃紙鍜屼腑鍫傦級
- 鍚勭渷瀹樺憳锛堝叿浣撳共娲荤殑鍏粏浠級
Step2:
鍐嶆潵纭畾鍚勪釜绫讳箣闂寸殑鍏崇郴锛?/p>
鏈€瀹规槗鐪嬪嚭鏉ョ殑鏄悇鐪佸畼鍛樻槸鍚屽儦鍏崇郴锛屼粬浠兘瑕佹帴寰呬咕闅嗭紝鍙槸鍦ㄧ殗涓婂崡宸$殑杩囩▼涓嚭鍦洪『搴忓拰鍋氱殑鍏蜂綋鎺ュ緟琛屼负涓嶄竴鏍凤紝姣斿锛?/p>
- 鐩撮毝鎬荤潱浼氬甫涔鹃殕鍘婚伩鏆戝北搴勶紝
- 灞变笢宸℃姎浼氬紶缃楃潃鐨囦笂绁嫓瀛斿簷锛?/li>
- 鑻忓窞缁囬€犺鐨囦笂娓歌鍥灄锛?/li>
- 鑰屾澀宸炵煡宸炲氨甯︾潃鐨囦笂鍘昏タ婀栬嫃鍫ゃ€?/li>
- 杩欓噷鍛婅瘔澶у OOD 涓竴涓紭鍖栬璁$殑灏忓彛璇€锛?strong>鍙樺寲鐨勬娊鎺ュ彛锛岀浉鍚岀殑寤烘ā鐗?/strong>銆?/li>
鎵€浠ユ垜浠湪杩欓噷闈㈠瀹樺憳浠笉鍚岀殑琛屼负锛屾渶濂芥妸浠栦滑鎶借薄鎴愭帴鍙f垨鑰呮娊璞$被锛岃繖閲屾垜浠噰鐢ㄥ畼鍛橈紙Official锛?br>杩欎釜鎶借薄绫汇€?/p>
鑰屽拰澶т汉浣滀负鎬荤锛屼粬鏃㈣鎺屾彙鐨囧笣鐨勫姩鍚戯紝鍙堣杈栧埗鍚勭渷瀹樺憳锛屾墍浠ュ湪绫荤殑灞傞潰涓婂拰澶т汉锛圥rimeMinister锛夎繖涓被灏卞緱鏈夋寚鍚戠殗甯濓紙Emperor锛夊拰瀹樺憳鍒楄〃鐨勫紩鐢ㄣ€?/p>
涓嬮潰涓?UML 鍥俱€?/p>
UML 鍥?/h2>
鍚勭渷鍚屽儦锛?/p>
鑰屼綘鍜屽ぇ浜猴紝浣滀负涔鹃殕闈㈠墠鐨勭孩浜猴紝寰楃粺绛瑰畨鎺掔殗甯濈殑琛岀▼锛屾棦瑕佹専鎸佺殗甯濓紝鍙堣鎺岀鍚勭渷瀹樺憳锛岃浠栦滑鏈夊簭鍦版墽琛屼换鍔★細
璐d换閾句竴鑸兘鑷冲皯鏈変竴涓澶勭悊鐨勫璞★紝浣滀负鍙傛暟浼犲叆鍚勪釜姝ラ锛岃繖閲岀殑涔鹃殕灏辨槸杩欎釜琚鐞嗭紙浼哄€欙級鐨勫璞°€?/p>浠g爜
浣滀负瀹樺憳杩欎釜鎶借薄绫伙紝鎴戜滑鑰冭檻鍒板疄闄呮儏鍐碉紝浠栬瀹夋帓涓€涓湴鏂瑰苟闄悓鐨囧笣鍙傝銆佹父瑙堬紝鍏跺疄灏辨槸涓€鍙ヨ瘽锛氫己鍊欑殗涓娿€?/p>
鎵€浠ヤ粬鏈変竴涓娊璞℃柟娉?serve锛屾帴鍙楃殗甯濓紙Emperor锛夎繖涓璞?/p>
@Data public abstract class Official { protected String title; protected abstract void serve(Emperor emperor); @Override public String toString() { return title; } }
杩欓噷涓轰簡鍖哄埆涓嶅悓鐨勫畼鍛橈紝鎴戜滑杩樼粰浜嗗畼鍛橈紙Official锛夌被涓€涓垚鍛樺彉閲?title銆?/p>
Official 涓嬮潰鏈夊叿浣撳疄鐜扮殑绫伙紝浠h〃鍚勭渷瀹樺憳锛屼粬浠嚜宸辨湁鑷繁鍏蜂綋鐨勬柟寮忓幓鏈嶅姟鍚剧殗锛屾瘮濡傜洿闅舵€荤潱锛屼粬鏄繖涔堝共鐨勶細
public class HebeiOfficial extends Official { public HebeiOfficial() { this.title = "鐩撮毝鎬荤潱"; } @Override protected void serve(Emperor emperor) { emperor.play(this, "閬挎殤灞卞簞"); } }
杩欓噷鍦?serve 閲岄潰瀹屽叏璁╁弬鏁?鐨囧笣"鑷繁鍐冲畾鎬庝箞鐜╋紝锛堥『渚胯鍙ラ澶栬瘽锛岃繖绉嶈鍙傛暟杩欎釜"澶栨潵鐨勫拰灏?蹇电粡鐨勬柟寮忥紝鍦ㄥ悇绉嶈璁℃ā寮忛噷寰堝父瑙併€傚鏋滄妸杩欓噷鐨?Emperor 鎹㈡垚 Comparator锛岀浉淇″緢澶氬皬浼欎即灏辨劅瑙夋湁鐐瑰儚绛栫暐妯″紡浜嗐€傝€屼笖"鐩撮毝鎬荤潱"涔熷彲浠ュ湪鐨囧笣 play 涔嬪墠鎴栬€呬箣鍚庡垎鍒仛涓€浜涗簨鎯咃紝杩欏儚涓嶅儚鐢?JDK 鐨勪唬鐞嗙殑鏃跺€欎腑閭d釜 InvocationHandler 瀵瑰緟 Method 鐨勬柟寮忥紵鎴栬€?Spring 涓浜?Aspect 鐨勫鐞嗭紵鍙﹀鍦?Visitor 绛夎璁℃ā寮忎腑浣犱篃鑳界湅鍒拌繖绉嶅啓娉曠殑韬奖锛?/p>
鍏朵粬瀹樺憳鐨勫啓娉曠被浼硷紝鍙槸鎹釜鍦版柟渚涚殗甯濇父瑙堣€屽凡锛屽弬瑙佸悗闈㈢殑杈撳嚭缁撴灉锛岃繖閲岀暐銆?/p>
鑰屼綔涓虹殗甯濓紝涔鹃殕鍙鐫€鐜╁氨濂斤紝褰撶劧浜嗭紝浣犲拰涓爞鍙互瀹夋帓褰撳湴鐨勫畼鍛橀櫔鍚岋紝鎵€浠?br>鐨囧笣绫诲彧鏈変竴涓?play 鏂规硶锛岃繖閲岀敤涓€涓瓧绗︿覆绠€鍗曡〃绀哄幓娓歌鐨勫湴鏂广€?/p>
涓轰簡闃叉涔鹃殕鍗椾笅鏈熼棿鏈変汉鍦ㄥ寳浜?鍙︾珛鏂板悰"锛堟墽琛?new Emperor()锛夛紝杩欎釜"鐨囧笣"瀵硅薄鐨勫垱寤鸿繃绋嬮噰鐢ㄤ簡鍗曚緥妯″紡锛屼繚璇佹暣涓?JVM 閲岄潰灏卞彧鏈夎繖涔堜竴涓殗涓婏紝鑰屼笖鍚嶅瓧鍙?涔鹃殕"锛?/p>
public class Emperor { private static final Emperor INSTANCE = new Emperor("涔鹃殕"); private final String name; private Emperor(String name) { this.name = name; } public static Emperor getInstance() { return INSTANCE; } public void play(Official official, String place){ System.out.println(official.getTitle() + " 瀹夋帓 " + name + "鐨囧笣娓歌浜? " + place); } }
鑰屼綘锛屽拰鐝呭拰澶т汉锛屽彧闇€瑕佹寜鍚勭渷椤哄簭锛屽悎鐞嗗畨鎺掑ソ涓嬮潰鐨勫畼鍛橈紝鐒跺悗璇峰嚭鐨囦笂骞舵槶鍛婂ぉ涓嬶細鍦d笂涓嬫睙鍗椾簡锛屾部閫斿悇鐪佸皬蹇冧己鍊欏氨濂斤細
public class PrimeMinister { private static List<Official> list = new ArrayList<>(); public static void main(String[] args) { // 涓嬩护娌块€斿悇鐪佸畼鍛樺噯澶囧ソ list.add(new HebeiOfficial()); list.add(new ShandongOfficial()); list.add(new JiangsuOfficial()); list.add(new ZhejiangOfficial()); // 璇峰嚭鐨囦笂 Emperor emperor = Emperor.getInstance(); // 鏄憡澶╀笅锛氫竾宀佺埛璧烽┚涓嬫睙鍗楋紒娌块€斿悇鐪佷緷娆′己鍊欏湥涓? System.out.println("涔鹃殕涓嬫睙鍗?"); start(list, emperor); } private static void start(List<Official> officials, Emperor emperor) { for (Official o : officials) { o.serve(emperor); } } }
鐪嬬湅锛屼綘鐨勪换鍔℃槸涓嶆槸绠€鏄庡浜嗭紝鍙渶瑕佺淮鎶ゅソ杩欎釜娌块€斿悇鐪佸畼鍛樼殑鑺卞悕鍐屽嵆鍙€?/p>
鏇撮噸瑕佺殑鏄紝浣犱笉鐢ㄤ翰鑷礋璐d簡锛屼笅闈㈢殑浜鸿皝鍔炰簨涓嶅姏锛屽氨瑕佽皝鐨勮剳琚嬶紒
鍙鑷繁鐨勮繖涓?鑺卞悕鍐?鎴栬€?琛岀▼琛?娌″啓閿欙紝鍜辩殑鑴戣灏辩畻淇濅綇鍟︺€?/p>
鑰屼笖鍚勪釜瀹樺憳鐨勪换鍔′篃姣旇緝鍗曚竴锛屼粬浠嚜宸变篃鏇翠笉瀹规槗鍑洪敊銆備笅闈㈡槸鏁翠釜琛岀▼妯℃嫙鐨勬墽琛屾儏鍐碉細
涔鹃殕涓嬫睙鍗? 鐩撮毝鎬荤潱 瀹夋帓 涔鹃殕鐨囧笣娓歌浜? 閬挎殤灞卞簞 灞变笢宸℃姎 瀹夋帓 涔鹃殕鐨囧笣娓歌浜? 鏇查槣瀛斿簷 鑻忓窞缁囬€?瀹夋帓 涔鹃殕鐨囧笣娓歌浜? 鑻忓窞鍥灄 鏉窞鐭ュ窞 瀹夋帓 涔鹃殕鐨囧笣娓歌浜? 瑗挎箹鑻忓牑
鍡紝涓€鍒囩湅涓婂幓浼间箮杩樹笉閿欙紝鍚勭渷瀹樺憳鎸夌収椤哄簭锛屼緷娆″畬鎴愪簡浠诲姟锛屾妸涓囧瞾鐖蜂己鍊欑殑杩樹笉閿欙紝娌℃湁浠€涔堝紓甯哥姸鍐靛彂鐢燂紝鎬荤畻鏉句簡鍙f皵銆?/p>
浣嗘槸锛岀幇鍦ㄦ潵浜嗕釜绐佸彂鎯呭喌锛氱殗涓婄獊鐒惰姹傦紝鍦ㄨ矾杩囧北涓滅殑鏃跺€欏姞涓€涓幆鑺傗€斺€斿ぇ鏄庢箹鐣斾笁鏃ユ父锛?/p>
涓哄暐瑕佺壒鎰忓幓閭i噷锛熷挶涔熶笉鏁㈤棶鍛愶紒鍙鍑嗗灏卞ソ銆?/p>
骞稿ソ鎴戜滑鐨勮绋嬪張宸茬粡鏈変簡澶ц嚧妗嗘灦锛岃刀绱ф煡锛屽ぇ鏄庢箹閭i噷褰掕皝绠★紝鍝︼紝娴庡崡鐭ュ簻锛屽氨鏄粬浜嗭紒
鐜板湪鍙渶鎶婁粬涔熷姞鍒?鑺卞悕鍐?锛氳矗浠ゆ祹鍗楃煡搴滃畨鎺掔殗涓婂湪澶ф槑婀栫晹涓夊ぉ鐨勮绋嬶紝涓嶅緱鏈夎锛屽惁鍒欐嬁浣犺瘯闂紒涓嬮潰鏄拰澶т汉杩欒竟瑕佸仛鐨勬敼鍔細
...浠ヤ笂鐣?.. list.add(new HeibeiOfficial()); // 鍔犲叆娴庡崡鐭ュ簻锛岃浠栧共娲伙紝浠栫煡閬撳湪澶ф槑婀栫晹璇ユ€庝箞鐜? list.add(new JinanOfficial()); list.add(new ShandongOfficial()); list.add(new JiangsuOfficial()); list.add(new ZhejiangOfficial()); ...浠ヤ笅鐣?..
鑰屽彟涓€杈规祹鍗楃煡搴滆繖閲岋紝浠栦篃鏄睘浜庡畼鍍氫綋鍒朵簡锛圤fficial 鐨勫瓙绫伙級锛屾墍浠ヤ篃瑕佹瀬灏芥墍鑳斤紝璁╁湥涓婂湪澶ф槑婀栫晹鐜╁緱寮€蹇冿細
public class JinanOfficial extends Official{ public JinanOfficial() { title = "娴庡崡鐭ュ簻"; } @Override protected void serve(Emperor emperor) { emperor.play(this, "澶ф槑婀栫晹"); } }
鍐嶆鎵ц绋嬪簭锛屾ā鎷熷湥涓婄殑琛岀▼锛岀粨鏋滆緭鍑哄涓嬶細
涔鹃殕涓嬫睙鍗? 鐩撮毝鎬荤潱 瀹夋帓 涔鹃殕鐨囧笣娓歌浜? 閬挎殤灞卞簞 娴庡崡鐭ュ簻 瀹夋帓 涔鹃殕鐨囧笣娓歌浜? 澶ф槑婀栫晹 灞变笢宸℃姎 瀹夋帓 涔鹃殕鐨囧笣娓歌浜? 鏇查槣瀛斿簷 鑻忓窞缁囬€?瀹夋帓 涔鹃殕鐨囧笣娓歌浜? 鑻忓窞鍥灄 鏉窞鐭ュ窞 瀹夋帓 涔鹃殕鐨囧笣娓歌浜? 瑗挎箹鑻忓牑
鍡紝杩欎笅鎬荤畻鍙堣繋鍚堜簡鍦f剰锛屼互鍚庣殗涓婂啀鏉ヤ粈涔堝叾浠栫殑琛岀▼涔熶笉鎬曚簡锛堝彧瑕佷粬涓嶅井鏈嶇璁匡紝寰湇绉佽鎮ㄦ壘绾檽宀氬幓鍟婏紝鍗曚竴璐d换鍘熷垯锛屼笓闂ㄧ殑绫诲共涓撻棬鐨勪簨鍎夸笉鏄紵锛夈€?/p>
鍙鎵惧埌褰撳湴鍏蜂綋鐨勫畼鍛橈紝涓€绾稿懡浠わ細浣犵粰鎴戞瀬灏芥墍鑳芥嫑寰呯殗涓婏紝鍏蜂綋鎬庝箞鎷涘緟锛屼綘鐪嬬潃鍔烇紝浼哄€欎笉濂戒竾宀佺埛锛屾垜瑕佷綘鑴戣锛?/p>
褰撶劧浜嗭紝鐨囧笣涔熷彲鑳戒复鏃跺垹鎺夊崡宸′腑鐨勬煇涓幆鑺傦紝鎴戜滑鐩存帴鎶婂畠浠庤绋嬪垪琛ㄤ腑鍒犻櫎灏卞ソ锛岃€屼笖浠€涔堟椂鍊欐兂鍐嶉噸鏂板姞杩涙潵杩樺彲浠ラ殢鏃舵坊鍔狅紝鍋氬埌浜嗗彲浠?鐏垫椿鎻掓嫈"锛屾妸浠g爜鐨勬敼鍔ㄥ噺鍒颁簡鏈€灏忥紝鏈夋柊鐨勪笟鍔¢€昏緫鍔犺繘鏉ョ殑鏃跺€欙紝鍙槸鍋氭坊鍔狅紝杩欐牱鏃笉瀹规槗鍑洪敊锛屼篃纭繚浜嗕唬鐮佺殑寮规€ф墿灞曪紝鑰屼笖褰撳墠璐d换閾句腑鐨勬楠わ紝濡傛灉娌℃湁鐘舵€佺浉鍏崇殑淇℃伅鐨勮瘽锛屼篃鍙互琚粍瑁呭埌鍏朵粬鐨勮矗浠婚摼涓€?/p>
鑰屼笖濡傛灉鏄垜浠殑鐪熷疄椤圭洰锛屾垜浠敋鑷冲彲浠ユ妸宸ヤ綔姝ラ鐨勫垪琛ㄩ厤缃湪 Spring Boot 鐨勯厤缃枃浠堕噷锛屽紑鍚祦绋嬬殑杩欎釜绫伙紝鍙璇诲彇閰嶇疆锛岀劧鍚庢妸鍚勪釜姝ラ渚濇鎵ц銆?/p>
杩欐牱濡傛灉鏈変慨鏀瑰彧瑕佹敼鍔ㄩ厤缃枃浠跺嵆鍙紝鍦?Java 浠g爜閲屾棤闇€浠讳綍鏀瑰姩銆?/p>
鎬荤粨涓庢嫇灞?/h2>
浠ヤ笂鍏跺疄鍙槸涓€涓矗浠婚摼妯″紡鏈€绠€鍗曠殑搴旂敤锛屽畠鏄竴涓湁搴忓垪琛ㄩ噷闈㈣浜嗗悇涓换鍔$殑姝ラ锛岀劧鍚庝緷娆¤繍琛屽埌鏈€鍚庛€?/p>
鎴戜滑鍙互鎶婂畠鍐欏湪鑷繁鐨勭▼搴忛噷锛屼篃鍙互鎶婂畠鎶借薄鍑烘潵鍋氭垚浜у搧锛岃鍏朵粬浜鸿嚜鐢辨墿灞曚笌閰嶇疆锛屽敖閲忓噺灏戦噸澶嶅埗閫犺疆瀛愩€?/p>
鏈夊緢澶氬伐浣滄祦寮曟搸渚挎槸杩欐牱锛屾瘮濡?
Activiti
銆?code>Netflix 鐨?Conductor
绛夈€備笉鍏夎繖浜涳紝灏辫繛浣?br>鏈€甯哥敤鐨?SpringMVC
鐢氳嚦鏄?Tomcat
閮界敤鍒颁簡璐d换閾炬ā寮忥紝鍙笉杩囦粬浠殑璐d换閾炬槸鍙屽悜鐨勶紝鍒嗗埆澶勭悊璇锋眰鍜屽搷搴旓紝鑰屼笖浠栦滑鐨勫鐞嗛『搴忔槸鍒氬ソ鐩稿弽鐨勶紝鏈川涓婃槸鐢ㄧ被浼奸€掑綊鐨勬柟娉曟搴忓€掑簭鍚勪究鍘嗕簡涓€娆★紙Filter 鎴?Interceptor 鐨勶級鏁扮粍銆?/p>鍙﹀鍦ㄤ竴浜涙寔缁泦鎴愬拰鎸佺画閮ㄧ讲鐨勬鏋朵腑锛屽
Jenkins
锛屼細鏈夌閬擄紙Pipeline锛夌殑姒傚康锛屽綋浣犲湪鍋氬嚭git push
鎻愪氦浠g爜涔嬪悗锛屼細瑙﹀彂鏁翠釜娴佺▼寮€濮嬩竴姝ユ鍦拌繍浣滐細鎷夊彇浠g爜锛圕heckout code锛夈€佹瀯寤猴紙Build锛夈€佹祴璇曪紙Test锛夌瓑锛岀洿鍒伴儴缃诧紙Deploy锛夊畬鎴愬苟杩愯鑴氭湰鍏抽棴鏃х増鏈殑鏈嶅姟骞跺惎鍔ㄦ渶鏂伴儴缃茬殑鏈嶅姟銆傝繖涓?娴佹按绾?锛圥ipeline锛夊叾瀹炰篃鏄竴涓彲浠ヨ浣犵敤浠g爜鑴氭湰鏉ラ厤缃殑璐d换閾俱€?/p>娌℃湁璐d换閾炬ā寮忕殑搴旂敤锛屼綘鐢氳嚦閮芥棤娉曡繍琛屼换浣曚竴涓?
Java
绋嬪簭銆傚洜涓虹被鍔犺浇涓€鑸伒寰?鍙屼翰濮旀淳"鏈哄埗锛屽疄闄呬笂鏄敤绫讳技閫掑綊鐨勬柟娉曟搴忓拰鍊掑簭鍚勪究鍘嗕簡涓€娆?Classloader
绫绘墍鏋勬垚鐨勯摼琛紙棰樺璇濓紝鎯虫妸涓€涓摼琛ㄧ炕杞繃鏉ワ紝鍙互鍙傝榻愬涔嬪墠鍐欒繃鐨勶細锛夛紝鍙笉杩囧叾涓殑閫昏緫姣旇緝澶嶆潅锛岃€屼笖杩樺簲鐢ㄤ簡"妯℃澘鏂规硶"杩欎竴璁捐妯″紡銆傜敱浜庢湰鏂囧彧鏄仛涓€涓矗浠婚摼妯″紡鐨勭畝鍗曞叆闂紝杩欎簺涓嶅仛杩囧灞曞紑浜嗐€?/p>缁间笂锛屽厖鍒嗙悊瑙e拰搴旂敤璐d换閾捐璁℃ā寮忥紝瀵规垜浠殑鏃ュ父宸ヤ綔鍜岄槄璇绘簮鐮侀兘寰堟湁甯姪锛岃兘璁╂垜浠湁鏁堟彁楂樹唬鐮佺殑鎵╁睍鎬у拰鍙鎬э紝甯屾湜瀵逛綘涔熸湁鎵€甯姪銆?/p>
濂戒簡锛屼互涓婂氨鏄湰鏂囩殑鍏ㄩ儴鍐呭锛屽鏋滀綘鍠滄杩欑瘒鏂囩珷锛岃寰楃粰鎴戠偣璧炵暀瑷€鍝︼綖浣犱滑鐨勬敮鎸佸拰璁ゅ彲锛屽氨鏄垜鍒涗綔鐨勬渶澶у姩鍔涳紝鎴戜滑涓嬬瘒鏂囩珷瑙侊紒
鎴戞槸灏忛綈锛岀航绾︾▼搴忓獩锛岀粓鐢熷涔犺€咃紝姣忓ぉ鏅氫笂 9 鐐癸紝浜戣嚜涔犲閲屼笉瑙佷笉鏁o紒
鏇村骞茶揣鏂囩珷瑙佹垜鐨?Github: https://github.com/xiaoqi6666...
以上是关于涓€鏂囧甫浣犵帺杞璁℃ā寮忎箣銆岃矗浠婚摼銆?/a>的主要内容,如果未能解决你的问题,请参考以下文章