Spring Boot 3 springdoc-openapi-ui doesn't work
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Spring Boot 3 has brought several enhancements to the Spring ecosystem, but with every major version, there are often changes that may cause issues with integrating libraries that rely on previous versions. When upgrading to Spring Boot 3, many developers have encountered challenges with the springdoc-openapi-ui library, a popular tool for generating OpenAPI documentation in a Spring Boot application. This article delves into some of the common issues faced and provides technical insights into resolving them.
Understanding the springdoc-openapi-ui Integration
springdoc-openapi-ui is a library that simplifies API documentation by generating OpenAPI 3 documentation based on a Spring Boot project's existing codebase. It leverages annotations in the code to produce an interactive Swagger UI for developers to test endpoints.
Typical Configuration
In a Spring Boot 2.x application, integrating springdoc-openapi-ui usually requires adding the following dependency to the pom.xml:
This would automatically expose the OpenAPI specification at /v3/api-docs and display the Swagger UI at /swagger-ui.html.
Issues with Spring Boot 3
Problem with Dependency Injection
One of the common issues encountered when migrating to Spring Boot 3 is related to changes in the classpath and dependency injection specific to the new version. The problem often manifests as a failure to start the application with errors indicating missing beans or failed injections.
Technical Explanation
In Spring Boot 3, the new features introduced could conflict with older versions of libraries, which rely on deprecated methods or APIs. The issue is often due to:
- Jakarta EE Transition: Spring Boot 3 is built on Jakarta EE 9, which means all the Java EE packages have been replaced with their Jakarta EE equivalents. Therefore, any library that uses traditional Java EE annotations or interfaces may face compatibility issues.
- Removal of Deprecated APIs: Spring Boot 3 has removed several deprecated APIs that may affect libraries built on older conventions.
Configuration Inconsistencies
Another issue developers face is the unexpected behavior or lack of proper documentation when accessing the Swagger UI or the OpenAPI specification.
Technical Explanation
This typically happens due to incorrect custom configurations in application.properties or application.yml. An example of this could be:
If these paths are not properly updated or reflected in the Spring Boot 3 application, it might lead to 404 errors when accessing the UI.
Resolving the Issues
Check and Update Dependencies
- Upgrade
springdoc-openapi-uiDependency: Ensure that you are using a version ofspringdoc-openapi-uithat is compatible with Spring Boot 3. This may mean upgrading to a newer version or checking the library's documentation for compatibility reports. - Handle Jakarta EE Packages: Replace Java EE imports and annotations with their Jakarta counterparts. For example:
instead of:
Adjust Configuration Files
Ensure that your application.properties or application.yml files are correctly set up to reflect any path changes or additional configurations needed for Spring Boot 3.
Enable Enhanced Diagnostics
Add diagnostic tools and logging mechanisms to identify the exact cause of failure during the initialization of the springdoc-openapi-ui. This helps trace issues arising due to dependency mismanagement or API deprecation.
Summary Table
Here is a summarized table highlighting the key issues and solutions:
| Issue | Explanation | Solution |
| Dependency Injection Failure | Conflicts due to deprecated APIs or Jakarta EE transitions | Upgrade dependencies, replace Java EE with Jakarta Packages |
| Incorrect Swagger UI Endpoints | Misconfigured paths in property files | Verify and correct path settings in configuration files |
| Missing Beans or Annotations | Hibernate Jakarta and API mismatches | Ensure correct version of libraries, update code annotations |
Conclusion
Transitioning to Spring Boot 3 offers advantages but requires careful management of dependencies and an understanding of architectural changes. Specifically, for springdoc-openapi-ui, resolving typical integration issues involves upgrading dependencies, revisiting configurations, and aligning with the new Jakarta EE standards. Awareness and preparedness can significantly smooth the migration process, ensuring that your API documentation tools work seamlessly with the latest Spring ecosystem.
This detailed examination of the problems and potential fixes should assist you when dealing with springdoc-openapi-ui integration on Spring Boot 3, ensuring that your applications remain robust and well-documented.
Related reading
- Spring boot 404 error custom error response ReST
- Spring Boot Actuator / Swagger
- Spring Boot Adding Http Request Interceptors
- Spring Boot Adding Http Request Interceptors
- Spring Boot 3.x upgrade. Could not resolve org.springframework.bootspring-boot-gradle-plugin3.0.1
- Spring Boot + Kafka + Kerberos configuration
- Spring Boot & Kafka, Producer thrown exception with key=''null''
- Spring Boot access static resources missing scr/main/resources

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.