java.lang.IllegalStateException: PathVariable annotation was empty on param 0.

Spring Cloud Zuul中的Filter加入一个Service,运行的时候报错:

java.lang.IllegalStateException: PathVariable annotation was empty on param 0.

要在@PathVariable后面加入value;

修改前:

@RequestMapping(value = "/hello/{name}", method = RequestMethod.GET)
String hello(@PathVariable String name);

修改后:

@RequestMapping(value = "/hello/{name}", method = RequestMethod.GET)
String hello(@PathVariable("name") String name);

参考:@PathVariable not working with feign · Issue #861 · spring-cloud/spring-cloud-netflix · GitHub


原文:java.lang.IllegalStateException: PathVariable annotation was empty on param 0._Python&Basketball的博客-CSDN博客
作者: Java-Basketball