




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
使用第2章-Eureka實踐作業(yè)中建好的中心,之前我們已經建好了服務生產者,現在在服ServiceControllerimportorg.springframework.web.bind.annotation.PathVariable;importorg.springframework.web.bind.annotation.RequestMap;import*CreatedbyMyonpublicclass{ ("publicStringo(@PathVariableStringname)returnname+"sayoEurekafrom}}##HTTP(Tomcat)port:name:micro-:returnname+" oEurekafrom{publicpublicclass*CreatedbyMyon<?<?xmlversion="1.0"encoding="UTF-<projectxmlns=" " <artifactId>spring-boot-starter-<relativePath/><!--lookupparentfromrepository--<project.build.sourceEncoding>UTF-<project.reporting.outputEncoding>UTF-<artifactId>spring-cloud-starter-<artifactId>spring-cloud-<artifactId>spring-boot-maven-##HTTP(Tomcat)port:name:micro-:service-defaultZone:#applicationservice-url:編寫啟動類,在啟動類上添加@SpringBootApplication@EnableDiscovery 這是一個Eureka importimportimport;import publicstaticvoidmain(String[]{SpringApplication.run(ControllerApplication.class,} te te()returnnew }}通過@LoadBalanced注解,調用netflix的ILoadBalancer實現客戶端負載均衡。然后通過CalloService、CalloController這兩個類去調用服務提供者提供的o接口,關鍵代碼importorg.springframework.beans.factory.annotation.Autowired;importorg.springframework.beans.factory.annotation.Value;importorg.springframework.http.ResponseEntity;*CreatedbyMyonpublicclass @Value("${app.service-privateStringpublicStringcallo(Stringname)//是一個ResponseEntityresult=restTemte.postForEntity(appServiceUrl+"o/"+name,null,return(String)}importorg.springframework.beans.factory.annotation.Autowired;importorg.springframework.web.bind.annotation.GetMap;importorg.springframework.web.bind.annotation.RestController;
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 公司房租租憑合同范本
- 勞動安全協(xié)議合同范本
- 包子店加盟簽約合同范本
- 人工打草合同范本
- 沖孔加工銷售合同范本
- 2024年河南省直第三人民醫(yī)院招聘筆試真題
- 第14課《回憶我的母親》教學設計 2024-2025學年統(tǒng)編版語文七年級上冊
- 力工合同范例
- 中國鐵建合同范本
- 包月工作合同范本
- 2024版消防設計質量問題案例分析手冊建筑機電專業(yè)
- 《業(yè)財一體化實訓教程-金蝶云星空V7.5》
- 工業(yè)機器人工作站系統(tǒng)組建課件 5.1康耐視is2000工業(yè)相機視覺識別操作
- 人教版二年級數學下冊第一單元綜合測評卷(含答案)
- 社區(qū)意識形態(tài)工作2025年度工作計劃
- 2025年山東省濟南廣播電視臺招聘30人歷年管理單位筆試遴選500模擬題附帶答案詳解
- DG-TJ 08-2048-2024 民用建筑電氣防火設計標準
- 2025年中智集團招聘筆試參考題庫含答案解析
- 肝癌圍手術期的護理
- 黑龍江省哈爾濱市南崗區(qū)2024-2025學年九年級上學期期末考試英語試題(含答案)
- 殘疾人就業(yè)培訓
評論
0/150
提交評論