Search code examples
javaspringspring-bootrest

SpringBoot3 Migration using PathVariable is not showing it as a Parameter, when call is done throwing 500 Internal Server Error


We migrated our Spring Boot 2.7.15 Application to 3.2.1. We updated our pom.xml to reflect all 3.2.1 specific dependencies

After the Spring Boot 3.2.1 Migration, noticed that for any @GetMapping including @PathVariable when request is made, we are getting 500 Internal Server Error.

Also Swagger shows: GET api/account/{fiscalYear} but does not show Parameters. Try it out also doesn't show any parameters. This was working fine with Spring Boot 2.7.15, having issue after Migration to Spring Boot 3.2.1

@RequestMapping("api/account")
public class AccountController {

    @Autowired
    AccountService accountService;


    @GetMapping(path = "/{fiscalYear}")
    public Response getAccountDetails(@PathVariable int fiscalYear) {
    ....
    }
}

Updated all pom entries to reflect Spring Boot 3.2.1


Solution

  • updating the method to following fixed the problem:

    @GetMapping(path = "/{fiscalYear}")
    public Response getAccountDetails(@PathVariable("fiscalYear") int fiscalYear) {
    ....
    }