Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Name for argument of type [java.lang.String] not specified, and parameter name information not available via reflection

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?

like image 531
Youcef Megoura Avatar asked Feb 02 '26 04:02

Youcef Megoura


2 Answers

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) {
    // ...
}
like image 53
Murat Yıldız Avatar answered Feb 03 '26 18:02

Murat Yıldız


Please include this configuration in your POM file

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <parameters>true</parameters>
    </configuration>
</plugin>

this configuration is important <parameters>true</parameters> For more details use this link

like image 30
Vikrant Avatar answered Feb 03 '26 17:02

Vikrant



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!