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);

参考:https://github.com/spring-cloud/spring-cloud-netflix/issues/861


原文:https://blog.csdn.net/superdangbo/article/details/80409075
作者: Java-Basketball