feignClient中修改ribbon的配置
1.使用@FeignClient注解发现服务
服务提供者的controller:
@RestController
public class StudentController {
@Autowired
private StudentService studentService;
@GetMapping("/getAll/{id}")
public Student getAll(@PathVariable("id")Integer id){
System.out.println("stu-provide:localhost:5865==>消费者查询学生时间:"+new Date().toLocaleString());
Student stu = studentService.getAllStu(id);
return stu;
}
}
消费者端:
//使用FeignClient 告知发布方的应用名称 默认使用ribbon进行负载均衡
@FeignClient(name="stu-provide")
public interface TestFeign {
@RequestMapping(value = "/getAll/{id}",method = RequestMethod.GET)
public Student getAll(@PathVariable("id") Integer id);
}