Quick revision
The short answer
In Spring Framework 7, a handler mapping can declare a version, for example @GetMapping(path = "/orders", version = "1.1"), and the application configures once how the version is read from each request: a header, a query parameter, a path segment or a media type parameter. Spring parses the request's version, checks it is supported, and picks the mapping whose version matches; a mapping declared as "1.2+" also serves later versions, so unchanged endpoints need not be copied. Configuration goes through configureApiVersioning in the MVC or WebFlux config, Boot 4 adds properties for it, and deprecation information can be sent with response headers, so we check the exact names and mechanisms in the release notes and reference docs.
What to remember
In this answer, we saw that Spring Framework 7 treats the API version as part of request mapping. The application configures once how the version is resolved, from a header, query parameter, path segment or media type, plus the supported versions and a default. Spring parses and validates the version, then matches it against the version attribute of the mappings, and baseline versions such as 1.2+ let unchanged endpoints serve later versions. Before relying on it, we confirm method and property names, Boot 4 support and the deprecation headers in the release notes for our versions.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
In Spring Framework 7, a handler mapping can declare a version, for example @GetMapping(path = "/orders", version = "1.1"), and the application configures once how the version is read from each request: a header, a query parameter, a path segment or a media type parameter. Spring parses the request's version, checks it is supported, and picks the mapping whose version matches; a mapping declared as "1.2+" also serves later versions, so unchanged endpoints need not be copied. Configuration goes through configureApiVersioning in the MVC or WebFlux config, Boot 4 adds properties for it, and deprecation information can be sent with response headers, so we check the exact names and mechanisms in the release notes and reference docs.
Why this question is asked
Every public API eventually needs a breaking change, and teams have long built their own versioning: a /v2 prefix here, a custom header filter there, a condition class that reads a media type somewhere else. Spring Framework 7 makes versioning a first-class part of request mapping in both Spring MVC and WebFlux. Interviewers ask about it because the feature is new, and because using it well depends on understanding how a version is resolved and matched, not just on the annotation. In this answer, we will recap why APIs are versioned, see how Spring reads a version, follow how it maps to a handler, look at baseline versions with a plus sign, and list what to confirm before relying on it.
1A Quick Recap of API Versioning
A breaking change is any change that makes an existing client fail, such as renaming a field, changing a type or removing an endpoint. Versioning lets the server offer the old and new behaviour side by side, so clients can move when they are ready. The version can travel in the URL path (/v2/orders), in a query parameter (?version=2), in a header (API-Version: 2) or in the media type (Accept: application/json;version=2).
Before Framework 7, Spring had no single model for this. Path versions were just part of the path, and the other styles needed custom request conditions or filters. Now the version is a property of the mapping, like the HTTP method or the path.
2Telling Spring Where the Version Is
First, the application decides how a version is read. This is configured once, in the MVC or WebFlux configuration, through configureApiVersioning. We choose one resolution strategy, declare the supported versions and decide what happens when a request has no version.
Versions are parsed as semantic versions by default, so 1.2 means major 1, minor 2, and comparisons such as 1.10 being later than 1.9 work as expected. A request with an unsupported version is rejected with a 400 Bad Request instead of silently reaching some handler.
3How a Version Is Mapped to a Handler
When a request arrives, Spring resolves its version with the configured strategy, parses it, and validates it against the supported versions. During handler lookup, the version becomes one more condition, next to path and method. Among the mappings for GET /orders, the one whose declared version matches the request wins.
- Read the versionheader, query, path segment or media type
- Version present?YesParse itNoUse the default, or reject if required
- Is it a supported version?YesMatch mappingsNo400 Bad Request
- Pick the matching mappingexact version, or the closest baseline with +
- Run the handleroptionally add deprecation headers
5 steps in order. Play them, or step through them one at a time.
4Baseline Versions With a Plus Sign
The plus sign is what keeps versioning manageable. Without it, releasing version 1.2 because one endpoint changed would force us to copy every other endpoint and mark it 1.2 too. A mapping declared as 1.1+ means: this handler serves 1.1 and any later supported version, unless a more specific mapping exists. So when we add 1.2 for a change in one endpoint, only that endpoint gets a new handler; all the others keep serving 1.2 through their baseline.
Notice that this works because supported versions are known. Spring knows 1.2 exists, so it can route a 1.2 request to the closest baseline at or below it.
5What to Check Before Relying On It
Because the feature is new, a few details deserve a careful read of the release notes and reference documentation for the exact versions we run. Check the exact configurer method names and defaults, including whether a version is required and what error is returned when it is missing. Check how path-segment versioning interacts with path patterns, since the mapping must account for the segment. Check the Spring Boot 4 properties for configuring versioning without code, and their exact names. Check the deprecation support: Spring can add headers telling clients that a version is deprecated and when it will be removed, such as Deprecation, Sunset and Link headers, and we should confirm which mechanism and headers are supported. Finally, check the client side, since RestClient and WebClient can insert a version into outgoing requests, and functional endpoints and tests have their own support.
6Follow-up questions
Which version resolution strategy works best with caches and gateways?
A path segment, and to a lesser degree a query parameter, because the version is part of the URL, which is what HTTP caches use as their key and what gateways route on most easily. A header or media type version also works, but every cache must be told to vary on it with a Vary header such as Vary: API-Version, and every gateway rule must read headers. Header versioning keeps URLs clean, so the choice is a trade-off, but whichever we pick should be the same across the organisation.
What happens to a request without any version?
That depends on configuration. We can set a default version so old clients that never sent one keep working, or require a version so the request fails with a 400. For a public API that already has clients, a default equal to the oldest version is the safe first step.
Does API versioning replace backward-compatible design?
No. Adding optional fields and new endpoints is still the best way to evolve an API, because no client has to do anything. Versioning is for the changes we cannot make compatible, and the fewer versions we have, the less code we maintain.
7Conclusion
In this answer, we saw that Spring Framework 7 treats the API version as part of request mapping. The application configures once how the version is resolved, from a header, query parameter, path segment or media type, plus the supported versions and a default. Spring parses and validates the version, then matches it against the version attribute of the mappings, and baseline versions such as 1.2+ let unchanged endpoints serve later versions. Before relying on it, we confirm method and property names, Boot 4 support and the deprecation headers in the release notes for our versions.
Open with
In Framework 7 the version becomes part of the mapping, like the path or the HTTP method. I declare it on the handler, for example @GetMapping with path /orders and version 1.1.
Then, if they want more
Separately, I configure once how the version is read, by implementing configureApiVersioning in the MVC or WebFlux config and choosing a request header, a query parameter, a path segment or a media type parameter, together with the supported versions and a default for clients that send none.
At request time Spring reads the version with that strategy, parses it as a semantic version, rejects it with a 400 if it is not supported, and then uses it as a condition when choosing between the mappings for that path.
The useful detail is the plus sign: a mapping with 1.1 plus serves 1.1 and any later version unless a more specific mapping exists, so when I release 1.2 for one changed endpoint, I do not have to duplicate all the others.
Before relying on it I would read the release notes and reference docs for the exact configurer methods and defaults, how path-segment versioning interacts with patterns, the property names Boot 4 adds, the client-side support in RestClient and WebClient, and the supported deprecation mechanism, such as Deprecation and Sunset headers.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Spring Framework 7, Spring Boot 4
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Framework reference, Core technologies
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Spring Framework 7 adds first-class API versioning to Spring MVC and WebFlux. Describe...": https://scrivio-interview-library.netlify.app/spring-boot/spring-framework-evolution/f6bde6932e/