I'm encountering an issue with Spring Boot. Recently, I upgraded the Spring Boot dependency to version 3.2.4.
When I attempt to call the following endpoint:
@PutMapping("/{uid}/test/{state}")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void update(
Context context,
@PathVariable String uid,
@PathVariable String state
) throws RuntimeFunctionalException {
this.service.updateState(uid, state, context);
}
Output:
Name for argument of type [java.lang.String] not specified, and parameter name information not available via reflection. Ensure that the compiler uses the '-parameters' flag
Is anyone else facing the same issue?
To fix the problem, add name for @RequestParam
and @PathVariable
annotations.
So, instead of this:
public ResponseEntity<CommandResponse> update(
@PathVariable long param1,
@RequestParam String param2) {
// ...
}
use this >>>
public ResponseEntity<CommandResponse> update(
@PathVariable("param1") long param1,
@RequestParam("param2") String param2) {
// ...
}