Springfox swagger not working in spring boot 2.2.0
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
When Springfox stops working after a Spring Boot upgrade, the failure is usually not "Swagger is broken" in the abstract. It is usually a dependency alignment problem, an autoconfiguration mismatch, or an outdated integration approach that no longer fits the Spring Boot version in the project.
What Usually Fails on Spring Boot 2.2
With Spring Boot 2.2.x, the common symptoms are:
- '
/swagger-ui.htmlreturns404' - '
/v2/api-docsis empty or errors' - the
Docketbean exists but no controllers are discovered - dependency conflicts produce startup errors
Older guides often mix springfox-swagger2, springfox-swagger-ui, and hand-written configuration copied from earlier Spring Boot versions. That combination can work, but it is sensitive to dependency drift.
Start with a Clean Dependency Set
If you are staying on Springfox, keep the dependency setup minimal and consistent. A common working approach is the Springfox Boot starter:
Then add one explicit configuration class:
This is easier to reason about than mixing older Springfox modules with custom UI wiring.
Check Controller Discovery
If the UI loads but shows no endpoints, the issue is often package scanning. The Docket above only scans com.example.api. If your controllers live under com.example.web, they will not appear.
A quick example controller:
After startup, verify:
If this endpoint fails, fix that first. The UI depends on the generated docs endpoint.
Common Causes Beyond Dependencies
Security configuration can block the Swagger endpoints. If Spring Security is active, permit the documentation paths explicitly:
Another cause is path customization. If the app runs behind a servlet context path or reverse proxy, the generated URLs may not match what the UI expects.
You should also avoid mixing incompatible transitive versions of Jackson, Spring MVC, or plugin libraries through unmanaged overrides in the build file.
When to Stop Fixing Springfox
Even if you can make Springfox work on Spring Boot 2.2, it is worth asking whether you should keep investing in it. Springfox has seen far less active maintenance than newer OpenAPI integrations.
For teams planning further upgrades, moving to springdoc-openapi is often the more stable direction. That is especially true if the codebase will later move to newer Spring Boot lines.
Still, if the immediate task is to get an existing 2.2 application unstuck, the shortest path is usually:
- align Springfox dependencies
- reduce configuration complexity
- verify controller scanning
- permit Swagger endpoints through security
Common Pitfalls
The biggest mistake is copying fragments from multiple tutorials into one project. Old dependency sets, new annotations, and custom security rules easily conflict.
Another common issue is debugging the UI before debugging /v2/api-docs. If the docs endpoint is broken, the UI problem is only a symptom.
Developers also forget package boundaries. A perfectly valid Docket can still document nothing if it scans the wrong base package.
Finally, treat Springfox as legacy infrastructure. If you need long-term compatibility, solving today’s 2.2 issue is not the same thing as choosing the best future tool.
Summary
- Springfox issues on Spring Boot 2.2 are usually dependency or configuration mismatches.
- Start with a clean Springfox dependency setup and a minimal
Docketbean. - Verify
/v2/api-docsbefore investigating the UI. - Make sure controller package scanning and security rules include the Swagger endpoints.
- Consider
springdoc-openapiif the project needs a better-maintained path forward.
Related reading
- SSD anchors in Tensorflow detection API
- SSL certificate rejected trying to access GitHub over HTTPS behind firewall
- Static hosting on Amazon S3 - DNS Configuration
- Static IP using Elastic Beanstalk
- Springfox Type javax.servlet.http.HttpServletRequest not present
- SpringRunner vs SpringBootTest
- Static outbound IP for AWS ECS Fargate task
- Static outgoing IP in Kubernetes

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.