Python知識分享網(wǎng) - 專業(yè)的Python學(xué)習(xí)網(wǎng)站 學(xué)Python,上Python222
深入探索Zookeeper:實戰(zhàn)應(yīng)用與高效策略 PDF 下載
發(fā)布于:2023-12-26 11:49:23
(假如點擊沒反應(yīng),多刷新兩次就OK!)

深入探索Zookeeper:實戰(zhàn)應(yīng)用與高效策略 PDF 下載  圖1

 

 

資料內(nèi)容:

 

 

代碼編寫:
配置 Resttemplate 支持負載均衡方式
1 @SpringBootApplication
2 public class UserCenterApplication {
3
4 public static void main(String[] args) {
5 SpringApplication.run(UserCenterApplication.class, args);
6 }
7
8
9 @Bean
10 @LoadBalanced
11 public RestTemplate restTemplate(){
12 return new RestTemplate();
13 }
14 }
編寫測試類:
TestController, Spring Cloud 支持 Feign, Spring RestTemplate,WebClient 以 邏輯名稱,
替代具體url的形式訪問。
1 import org.springframework.beans.factory.annotation.Autowired;
2 import org.springframework.web.bind.annotation.GetMapping;
3 import org.springframework.web.bind.annotation.RestController;
4 import org.springframework.web.client.RestTemplate;
5
6 @RestController
7 public class TestController {
8
9 @Autowired
10 private RestTemplate restTemplate;
11
12 @GetMapping("/test")
13 public String test(){
14 return this.restTemplate.getForObject( "http://product‐center/getInfo" ,Stri
ng.class);
15 }
16 }