Spring MVC 遇到过的问题

解决方案:PathVariable annotation was empty on param 0.

解决方案

原代码中的 @PathVariable 没有写 value 参数。

1
2
3
4
5
6
@FeignClient(name = "eureka-client", configuration = FeignConfig.class)
public interface EurekaFeignClient {

@GetMapping("/hello/{name}")
public String index(@PathVariable String name);
}

应该为

1
2
3
4
5
@FeignClient(name = "eureka-client", configuration = FeignConfig.class)
public interface EurekaFeignClient {

@GetMapping("/hello/{name}")
public String index(@PathVariable(value = "name") String name);