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

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个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!