wuxw7
2017-04-05 678ebc7cc519bcbe42b30edbc6070381ea1016e9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.java110.feign.test;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
 
/**
 *
 * 服务测试
 *
 * ribbon
 *
 * feign
 *
 *
 * Created by wuxw on 2017/4/5.
 */
@RestController
public class TestController {
 
    @Autowired
    private RestTemplate restTemplate;
 
    @Autowired
    private TestFeignHystrixClient testFeignHystrixClient;
 
    @GetMapping("/test/{id}")
    public String sayHello(@PathVariable Long id) {
        return restTemplate.getForObject("http://user-service/test/sayHello?param="+id,String.class);
    }
 
    @GetMapping("/testFeign/{id}")
    public String sayHelloFeign(@PathVariable Long id){
        return testFeignHystrixClient.sayHello(""+id);
    }
}