Skip to content

NoSuchMethodError: 'ControllerAdviceBean.<init>(Object)' with Spring Boot 3.5.x and springdoc-openapi 2.5.x #3041

@kkw-11

Description

@kkw-11

Describe the bug

  • When using Spring Boot 3.5.3 (Spring Framework 6.2.x) with springdoc-openapi-starter-webmvc-ui:2.5.0, I get the following error when accessing Swagger: java.lang.NoSuchMethodError: 'void org.springframework.web.method.ControllerAdviceBean.(java.lang.Object)'
  • I found that Spring Framework 6.2.x has removed the constructor ControllerAdviceBean(Object) which SpringDoc 2.5.0 depends on.

To Reproduce
Steps to reproduce the behavior:

  1. Use Spring Boot 3.5.3 (spring-boot-starter-web).
  2. Add springdoc-openapi-starter-webmvc-ui:2.5.0.
  3. Access /swagger-ui/index.html or /v3/api-docs.
  4. Application throws NoSuchMethodError and Swagger does not load.
    -Spring Boot version: 3.5.3
  • Spring Framework version: 6.2.8
  • SpringDoc version: 2.5.0
  • Expected Result: Swagger UI should load without errors.
  • Actual Result: Application crashes with NoSuchMethodError.

Expected behavior

  • A clear and concise description of what you expected to happen.
  • What is the expected result using OpenAPI Description (yml or json)?

Screenshots & SampleCode

Image Image
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public ResponseEntity<String> handleAll(Exception e) {
        return ResponseEntity.status(500).body("Internal Server Error");
    }
}

Additional context

  • Upgrading SpringDoc to 2.8.9 resolves the issue.
  • This issue seems to come from Spring Framework 6.2.x API changes.
  • It would help if Spring Boot - SpringDoc compatibility is documented more clearly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis doesn't seem right

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions