一切顺势而行 2019-06-23 22:08 采纳率: 17.6%
浏览 376
已结题

springcloud 带参 reestTemplate 400 null FeignClient client not found 已经加入ribbon 的包

http://localhost:8090/getStudentName?studentName=wangwu

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Sun Jun 23 21:57:37 CST 2019
There was an unexpected error (type=Internal Server Error, status=500).
400 null

Sun Jun 23 22:02:32 CST 2019
There was an unexpected error (type=Internal Server Error, status=500).
com.netflix.client.ClientException: Load balancer does not have available server for client: client

服务发布类

@RestController
public class StudentController {

@GetMapping("getStudentName")
public String getStudentName(@RequestParam("studentName")String studentName) {  
    return "hellworld";
}   

}
服务restTemplate 和FeignClient调用带参数

@Autowired
private RestTemplate restTemplate;

@Autowired
private StudentService studentService;

@GetMapping("getStudentName")
public String getStudentName(@RequestParam("studentName")String studentName) {

    return restTemplate.getForObject("http://eureka-server/getStudentName", String.class,studentName);
}

@GetMapping("getStudentNameByFeign")
public String getStudentNameByFeign(@RequestParam("studentName")String studentName) {
    return studentService.getStudentNameByFeign(studentName);
}

Feign client  接口类

public interface EurekaClientFeign{
@GetMapping("getStudentName")
public String getStudentName(@RequestParam("studentName")String studentName);

}

服务层实现

@Service
public class StudentService {
@Autowired
private EurekaClientFeign client;

public String getStudentNameByFeign(String studentName) {
    return client.getStudentName(studentName);
}

}
请问出现上述问题,调用无参数数的是没有任何问题,请教哪位大佬给予提供解答

  • 写回答

1条回答

  • dabocaiqq 2019-06-24 09:25
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?