Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Documents API versioning for Spring MVC and WebFlux in Spring Boot 4 and Framework 7: mapping, resolution, defaults, and deprecation.
48% 91%+43 ptsof test cases passed
Passed 21 of 23 test cases with the skill, and 11 of 23 without it.
3 of 3 safety checks passed
Not used yet
Spring Framework 7 provides API versioning in the mapping layer. Prefer it over hand-rolled
/v1 prefixes, custom HandlerMapping implementations, or version-sniffing filters.
@RestController
@RequestMapping("/api/orders")
class OrderController {
@GetMapping(path = "/{id}", version = "1.0")
OrderV1 getV1(@PathVariable UUID id) { ... }
@GetMapping(path = "/{id}", version = "1.2")
OrderV2 getV2(@PathVariable UUID id) { ... }
}
Use semantic version strings. A + suffix means the mapping handles that version and newer
versions, for example version = "1.2+".
@Configuration
class WebConfig implements WebMvcConfigurer {
@Override
public void configureApiVersioning(ApiVersionConfigurer configurer) {
configurer
.useRequestHeader("API-Version")
.setDefaultVersion("1.0")
.addSupportedVersions("1.0", "1.2");
}
}
Choose exactly one source: request header, query parameter, path segment, or media-type parameter. Keep the choice consistent across the application. WebFlux uses the corresponding
Next to this one in the catalogue, plus more from the same author.