原因
没有显示地指定参数名称
@GetMapping("/hello/{name}")
public String hello(@PathVariable String name) {
return helloService.sayHello(name);
}
改为下面格式即可
@GetMapping("/hello/{name}")
public String hello(@PathVariable("name")String name) {
return helloService.sayHello(name);
}
或者添加maven插件
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version> <!-- Replace with the version you need -->
<configuration>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration>
</plugin>