Scrivio Interview library
DesignAdvanced6 min read · updated 12 November 2026

Your company has 70 Spring MVC services, each with its own WebMvcConfigurer for CORS, interceptors, converters and path matching, and behaviour differs subtly between them. Design a shared approach without blocking teams from legitimate customisation.

I would build a platform starter whose @AutoConfiguration classes register the shared interceptors, converters, CORS rules and error handling, each controlled by properties, and guarded by @ConditionalOnMissingBean and @ConditionalOnProperty so teams can turn off or replace a part explicitly and visibly. Shared components get documented order values relative to Spring Security, @EnableWebMvc is banned with an ArchUnit rule because it disables auto-configuration, and the starter is tested against each supported Spring Boot version and released with a migration note.

Why this question is asked

Seventy services with seventy WebMvcConfigurers means seventy slightly different behaviours: one service matches trailing slashes and another does not, one returns dates as numbers, one forgets the CORS origin for the new mobile app. Each difference is small, but together they make every cross-service change slow and every incident harder to diagnose. Interviewers ask this to see whether we can centralise behaviour without becoming the platform team that blocks everyone. In this answer, we will look at where the differences come from, design the starter, give teams clear ways to opt out or replace parts, fix the order, enforce the one rule that cannot be optional, and plan testing and releases.

1Where the Differences Come From

Most of the drift is copying plus time. A WebMvcConfigurer was copied from an older service, then each team fixed what hurt them. Some differences are real choices, but many are accidents: different allowed origins because a list was updated in only some services, a different Jackson date format because one service replaced the converter list, or different path matching because older services were written when Spring matched suffixes and trailing slashes by default and newer ones were not.

A good design separates the two. Accidental differences should disappear because the shared default is simply used. Real choices should stay possible but become visible in configuration, so anyone can see that service X deliberately differs.

2The Platform Starter

A Spring Boot starter is a dependency that brings auto-configuration: classes annotated @AutoConfiguration and listed in the file META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports. Boot evaluates them at startup like its own. Our starter contributes a WebMvcConfigurer that registers the shared pieces, plus the beans behind them, each bound to properties under a common prefix.

Java
@AutoConfiguration(after = WebMvcAutoConfiguration.class)
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
@EnableConfigurationProperties(PlatformWebProperties.class)
public class PlatformWebAutoConfiguration {
@Bean
@ConditionalOnMissingBean // a team can supply its own
TenantInterceptor tenantInterceptor(TenantRepository tenants) { return new TenantInterceptor(tenants); }
@Bean
@ConditionalOnProperty(prefix = "platform.web.cors", name = "enabled", matchIfMissing = true)
CorsConfigurationSource platformCors(PlatformWebProperties props) {
var config = new CorsConfiguration();
config.setAllowedOrigins(props.getCors().getAllowedOrigins());
config.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE"));
var source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/api/**", config);
return source; // used by Spring Security and MVC
}
@Bean
WebMvcConfigurer platformWebMvcConfigurer(TenantInterceptor tenant, PlatformWebProperties props) {
return new WebMvcConfigurer() {
@Override public void addInterceptors(InterceptorRegistry r) {
if (props.getTenant().isEnabled()) {
r.addInterceptor(tenant).addPathPatterns("/api/**")
.excludePathPatterns(props.getTenant().getExcluded().toArray(String[]::new))
.order(PlatformOrder.TENANT_INTERCEPTOR);
}
}
};
}
}
# A service's application.yml
platform.web.cors.allowed-origins: https://app.example.com, https://m.example.com
platform.web.tenant.excluded: /api/health, /api/public/**

Notice that the starter adds to Boot's MVC configuration rather than replacing it, so Boot's Jackson setup, static resources and error handling keep working. Jackson defaults shared across the company are set through a customizer bean in the same starter, not by replacing converters.

3Letting Teams Customise Without Forking

Teams need three kinds of control, and each has an explicit, visible mechanism. To turn a part off, they set a property such as platform.web.tenant.enabled=false, guarded in the starter by @ConditionalOnProperty or a check like the one above. To replace a part, they declare their own bean of the same type, and @ConditionalOnMissingBean makes the starter's version step aside. To add something, they write their own WebMvcConfigurer, which simply adds to the starter's.

Because all three are in configuration or a declared bean, a reviewer, or a script scanning the repositories, can see every deviation. That is the difference from today's world, where a deviation is a changed line inside a copied class.

Step throughHow a team adapts the shared behaviour
  1. Is the shared default right for us?
    Yesdo nothing, just add the starterNocontinue
  2. Do we need it at all?
    YescontinueNoturn it off with a property
  3. Is a setting enough, such as an extra origin?
    Yeschange the propertyNodeclare our own bean
  4. Deviation is visible in config or codereviewable and searchable

4 steps in order. Play them, or step through them one at a time.

4Predictable Order and the One Hard Rule

Interceptors and filters from the starter get fixed order values, defined as constants in a PlatformOrder class and documented relative to Spring Security's filter chain, which Boot registers at spring.security.filter.order, -100 by default. Teams that add their own pick values relative to these constants, so nobody has to guess whether their filter runs before or after the tenant check.

One rule is not optional: no @EnableWebMvc in services. It makes Boot's WebMvcAutoConfiguration back off, which removes Boot's converters and static resources and, depending on ordering, can bypass parts of our starter. We enforce it with an ArchUnit test shipped in a shared test library, so the build fails rather than a reviewer having to notice.

Java
@AnalyzeClasses(packages = "com.example")
class PlatformRules {
@ArchTest
static final ArchRule noEnableWebMvc =
noClasses().should().beAnnotatedWith(EnableWebMvc.class)
.because("it disables Spring Boot's MVC auto-configuration and the platform starter");
}
// A service with @EnableWebMvc -> build fails with the reason above

5Testing and Releasing the Starter

The starter's own test suite uses ApplicationContextRunner, Boot's tool for testing auto-configuration in isolation, to check that each bean appears by default, disappears with its property, and steps aside for a user bean. Web slice tests then check the behaviour: CORS headers for allowed origins, the tenant interceptor skipped for excluded paths, ISO dates in JSON.

CI runs this suite against every Spring Boot line the company supports, for example 3.5 and 4.0, and against the next milestone, so incompatibilities appear before services meet them. Each release has a short migration note that lists behaviour changes and the property that restores the old behaviour, if there is one. We then roll services onto the starter gradually, starting with a few volunteer teams, deleting their copied configuration as they adopt it, and tracking adoption across the 70 services.

6Follow-up questions

Why not just publish a base WebMvcConfigurer class for teams to extend?

Because inheritance brings back copying and drift: teams override methods, forget to call super, and their changes are invisible in configuration. Auto-configuration with properties and conditional beans gives the same defaults with explicit, searchable deviations and no code in each service.

How do you handle a team whose needs conflict with the default?

First check whether the default is wrong for everyone; often a team's complaint reveals a better default. If the need is truly local, they use the opt-out or replacement mechanism, and we record why. If many teams opt out of the same thing, that is a sign to change the starter.

How do you unify path matching across old and new services?

Make the starter's behaviour match current Spring defaults, PathPatternParser and no trailing slash matching, and give services that still rely on old behaviour a temporary, documented way to keep it, such as an explicit redirect for trailing slashes. Track those exceptions and remove them as clients are updated.

7Conclusion

In this answer, we designed a platform starter whose auto-configuration registers shared interceptors, CORS, converter settings and error handling, controlled by properties. @ConditionalOnProperty and @ConditionalOnMissingBean let teams turn parts off or replace them visibly instead of forking code. Shared components have documented order values relative to Spring Security, @EnableWebMvc is banned with an ArchUnit rule, and the starter is tested with ApplicationContextRunner and web slices against each supported Spring Boot version, with migration notes for every release.

What to say in the interviewAbout 90 seconds aloud

Open with

I'd replace the seventy copied WebMvcConfigurers with a platform starter. It has @AutoConfiguration classes, registered in the AutoConfiguration.imports file, that contribute a WebMvcConfigurer with the shared interceptors, a CorsConfigurationSource used by both Security and MVC, Jackson defaults through a customizer, and common error handling, all driven by properties like platform.web.cors.allowed-origins.

Then, if they want more

It adds to Boot's MVC setup rather than replacing it. For flexibility, every part is either behind @ConditionalOnProperty, so a team can switch it off with one property, or @ConditionalOnMissingBean, so a team can declare its own bean and the starter steps aside, and teams can still add their own WebMvcConfigurer.

The key point is that every deviation becomes visible in config or a declared bean, instead of a changed line in a copied class. Ordering is explicit: interceptor and filter order constants documented relative to Spring Security's minus 100.

One rule is hard: no @EnableWebMvc, because it makes Boot's auto-configuration back off and breaks the starter, and I'd enforce it with an ArchUnit test in a shared test library. The starter is tested with ApplicationContextRunner for the conditions and MockMvc for behaviour, against every supported Boot line and the next milestone, with a migration note on each release.

Then we roll it out with volunteer teams first, delete their copied config, and track adoption across the seventy services.

About this answer

Last updated
12 November 2026
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.
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 "Your company has 70 Spring MVC services, each with its own WebMvcConfigurer for CORS...": https://scrivio-interview-library.netlify.app/spring-boot/mvc-architecture/0ddce0a95d/