package com.example.demo.controller;
import com.example.demo.service.AsyncService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
@RestController
@RequestMapping("/async")
public class AsyncController {
@Resource
private AsyncService asyncService;
/**
* 测试eureka
*/
@Resource
RestTemplate restTemplate;
@RequestMapping("/test1")
public void fun01(){
// 服务id
String serverId = "TEST";
// 通过服务id 调用
ResponseEntity<Map> responseEntity = restTemplate.getForEntity("http://" + serverId + "/async/test", Map.class);
09-15
1313
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-07
975
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-29
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交