The springfox-swagger2 dependency generated Swagger 2 (OpenAPI 2.0) documentation from Spring MVC controllers and served it through Swagger UI. It is now effectively obsolete: Springfox has not had a release since 3.0.0 in 2020, and it does not support Spring Boot 3 or Jakarta EE. For new and upgraded projects, use springdoc-openapi, which generates OpenAPI 3 documents.
This article explains what Springfox did, why it stopped working on current Spring Boot versions, and how to migrate.
Springfox inspected your Spring MVC mappings at startup and built a Docket bean describing the API. The artifact io.springfox:springfox-swagger2 produced the JSON at /v2/api-docs, and springfox-swagger-ui bundled the browser UI at /swagger-ui.html.
A typical configuration looked like this:
@EnableSwagger2 and DocumentationType.SWAGGER_2 refer to the old Swagger 2 specification. Version 3.0.0 added OpenAPI 3 support with springfox-boot-starter, but the project was never updated after that.
| Problem | Detail |
|---|---|
| Unmaintained | No release since 3.0.0 in 2020; open issues and security fixes are not addressed |
| Spring Boot 2.6+ path matching | Boot switched to PathPatternParser, which broke Springfox startup with a NullPointerException in WebMvcRequestHandler unless you set spring.mvc.pathmatch.matching-strategy=ant_path_matcher |
| Spring Boot 3 and Jakarta | Springfox uses javax.* packages; Boot 3 uses jakarta.*, so it cannot run there |
| Swagger 2 only for the classic starter | Modern tooling expects OpenAPI 3.x |
The path matching workaround kept some Boot 2.6 and 2.7 applications alive, but it is a dead end. You cannot upgrade to Boot 3 while keeping Springfox.
springdoc-openapi is actively maintained and supports Spring Boot 3 and newer, including WebFlux. For Spring MVC on Boot 3, add the starter that includes Swagger UI:
Check the springdoc compatibility table for the version that matches your Spring Boot release, because springdoc major versions follow Boot majors. No Docket bean is needed. Start the application and open:
/v3/api-docs for the OpenAPI JSON/swagger-ui.html for the interactive UITo customise the metadata, declare an OpenAPI bean.
The old io.swagger.annotations package is replaced by io.swagger.v3.oas.annotations.
| Springfox / Swagger 2 | OpenAPI 3 replacement |
|---|---|
@Api | @Tag |
@ApiOperation | @Operation |
@ApiParam | @Parameter |
@ApiModel | @Schema on the class |
@ApiModelProperty | @Schema on the field |
@ApiResponse | @ApiResponse (new package) |
@ApiIgnore | @Hidden |
Common settings live in application.properties:
With Spring Security, permit the documentation endpoints or protect them according to your policy. In production many teams disable the UI with springdoc.swagger-ui.enabled=false and expose only the JSON, or serve it only on an internal profile.
The project is unmaintained rather than formally deprecated, with its last release in 2020. It does not support Jakarta namespaces, so it cannot run on Spring Boot 3 or later.
Setting spring.mvc.pathmatch.matching-strategy=ant_path_matcher is the known workaround. It is a temporary fix, and the lasting solution is to move to springdoc-openapi.
No. It generates OpenAPI 3.x. Modern clients, code generators and gateways read OpenAPI 3, and you can still export the JSON for them.
The annotations from io.swagger.annotations are not recognised by springdoc, so replace them with io.swagger.v3.oas.annotations equivalents as in the table above.
The springfox-swagger2 dependency was the classic way to generate Swagger 2 docs for Spring MVC, but it is no longer maintained and fails on Spring Boot 2.6 path matching and on Spring Boot 3 entirely. Replace it with springdoc-openapi, swap the annotations for their OpenAPI 3 versions, and secure or disable the Swagger UI in production.