Scrivio Interview library
LeadershipPrincipal6 min read · updated 12 November 2026

Internal starters from different platform teams keep conflicting over beans of the same type, such as ObjectMapper, RestClient builders and DataSource. What governance would you set for how shared libraries contribute beans?

I would set a short, enforced set of rules: shared libraries contribute beans only through auto-configuration guarded by @ConditionalOnMissingBean; they never put @Primary on common types such as ObjectMapper, RestClient.Builder or DataSource, and use customisers or qualified names instead; a registry records which starter owns each shared bean type; a compatibility build tests commonly used starters together; and the rules are published, with new starters reviewed against them before release.

Why this question is asked

When several platform teams each ship a starter, every one of them is reasonable on its own, and the conflicts appear only when an application uses three of them together: two ObjectMappers, a RestClient.Builder that loses the tracing settings, a DataSource that one starter quietly redefines. The application teams then spend days on startup failures they did not cause. Interviewers ask this leadership question to see whether we can turn a recurring technical problem into a lightweight governance system that people actually follow. In this answer, we will look at why the conflicts happen, then go through the rules, the ownership registry, the compatibility build and the review process, and how to introduce them without slowing teams down.

1Why Starters Collide

A Spring Boot starter is a dependency that brings auto-configuration, configuration classes that Spring Boot loads automatically when the starter is on the classpath. Two starters collide when both try to own the same bean type. The common patterns are a starter defining an ObjectMapper with @Primary, a starter defining its own DataSource without a condition so it overrides the application's, and two starters each building a RestClient.Builder with different interceptors, so one of them silently loses its settings depending on which bean wins.

The cause is rarely carelessness. Each team tested its starter alone, where everything worked. Nobody owned the question of how starters behave together, so nobody tested it.

Typical conflicts between internal starters
Shared typeWhat a starter didSymptom in the app
ObjectMapper@Primary bean with its own settingstwo primaries: startup fails
RestClient.Buildernew builder bean, no conditiontracing or auth interceptors lost
DataSourceunconditional @Beanapp's own DataSource overridden
MeterRegistry filtersglobal filters on all metersother teams' metrics renamed

2Rule 1: Contribute Through Auto-Configuration That Backs Off

Every bean a library contributes for a shared type must come from an auto-configuration class and carry @ConditionalOnMissingBean. Auto-configuration runs after the application's own configuration, so the application's bean always wins and the library's default appears only when nobody else defined one.

We also forbid component scanning of library packages, because scanned beans are registered with the application's configuration and cannot reliably back off. A short code sample in the rules makes this concrete for every team.

Java
@AutoConfiguration
class PaymentsClientAutoConfiguration {
@Bean @ConditionalOnMissingBean(name = "paymentsRestClient")
RestClient paymentsRestClient(RestClient.Builder builder) { // uses the shared builder, does not define one
return builder.baseUrl("https://payments.internal").build();
}
}

3Rule 2: No @Primary on Common Types

@Primary on a common type takes the decision away from the application and guarantees a conflict with the next library that does the same. Libraries that want to influence a shared bean contribute a customiser instead: a Jackson builder customiser for ObjectMapper, a RestClientCustomizer for RestClient.Builder, a MeterFilter scoped to their own meter names. Libraries that need their own instance, such as a payments RestClient, register it under a clear qualified name like paymentsRestClient and inject it by that name, so it never competes for plain injection.

4Rule 3: A Registry of Who Owns Each Shared Type

For each shared bean type, one owner is written down: usually Spring Boot itself for ObjectMapper and RestClient.Builder, and a specific platform team for internal types such as a TenantContext or an AuditPublisher. The registry is a simple page or a file in the platform repository listing the type, the owner, how other starters may extend it, and the bean names already taken.

The registry turns arguments into lookups. When a new starter wants to change JSON behaviour, the answer is already written: Spring Boot owns ObjectMapper, contribute a customiser with an order in the platform range. When two teams both want to own a type, the conflict is resolved once, in a review, rather than every time an application team hits it.

5Rule 4: A Compatibility Build

Rules on paper do not catch everything, so we add one CI build that pulls in the commonly used starters together, the top ten by adoption, for example, and starts a sample application with them. The tests assert the things that matter: exactly one ObjectMapper and it honours spring.jackson properties; the shared RestClient.Builder carries the tracing and auth interceptors from every starter; an application-defined DataSource is the one in use.

Java
@SpringBootTest(classes = CompatApp.class) // depends on all popular internal starters
class StarterCompatibilityTest {
@Autowired ApplicationContext ctx;
@Test void oneObjectMapper() { assertThat(ctx.getBeansOfType(ObjectMapper.class)).hasSize(1); } // passes
@Test void builderHasTracing() { assertThat(interceptorsOf(ctx.getBean(RestClient.Builder.class)))
.contains("tracing", "tenant-header"); } // passes
}

Every starter release runs this build before publishing. A starter that breaks it does not ship, and the failure is seen by the team that caused it, not by an application team three weeks later.

6Publishing the Rules and Reviewing New Starters

I would write the rules on one page with the reasons and a code example for each, because rules without reasons get argued about and rules without examples get misread. New starters, and changes that add beans of shared types, get a short review by the platform architecture group against a checklist; most reviews take minutes. Existing starters are brought into line by their owners within an agreed period, with the compatibility build switched from warning to failing once the known violations are fixed.

The aim is that application teams can add any approved starter without thinking about bean conflicts. I would measure success by the number of startup-conflict incidents and support requests, which should fall to near zero within a couple of release cycles.

Step throughLife of a new internal starter
  1. Team designs starterchecks the ownership registry for shared types
  2. Follows the rulesauto-configuration, @ConditionalOnMissingBean, customisers, qualified names
  3. Passes architecture checklist review?
    YesAdd to compatibility buildNoFix and resubmit
  4. Compatibility build green?
    YesPublish releaseNoFix before release
  5. Registry updatednew bean names and extension points recorded

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

7Follow-up questions

How do you get platform teams to accept these rules?

Show them the cost first: the incidents and support hours caused by conflicts, with names of real affected applications. Then involve them in writing the rules, so each team sees its own constraints reflected, and keep the rules few. People follow a short list they helped shape far more readily than a long one handed down.

What if a starter genuinely needs to change a shared bean's behaviour?

It contributes a customiser and documents what it changes, so the change is visible, ordered and overridable by the application. If a customiser cannot express it, that is a signal to discuss with the owner of the type, recorded in the registry, rather than to take over the bean.

Can this be enforced automatically?

Partly. ArchUnit tests or a custom static check can fail the build when a starter uses @Primary, defines a bean of a registered shared type without @ConditionalOnMissingBean, or uses component scanning. The compatibility build catches the behavioural conflicts that static checks cannot see. The review remains for design questions.

8Conclusion

In this answer, we turned a recurring problem, internal starters fighting over ObjectMapper, RestClient builders and DataSource, into a light governance system. Libraries contribute beans only through auto-configuration that backs off with @ConditionalOnMissingBean, avoid @Primary on common types in favour of customisers and qualified names, and record ownership of shared types in a registry. A compatibility build tests popular starters together on every release, and published rules with reasons, plus a short review for new starters, keep the system working without slowing teams down.

What to say in the interviewAbout 80 seconds aloud

Open with

I would treat this as a missing ownership problem: each starter was tested alone, and nobody owned how they behave together. So I would set four rules and a process.

Then, if they want more

First, libraries contribute beans only through auto-configuration with @ConditionalOnMissingBean, never through component scanning, so the application's own bean always wins. Second, no @Primary on common types like ObjectMapper, RestClient.Builder or DataSource.

A library that wants to influence a shared bean contributes a customiser, such as a Jackson builder customiser or a RestClientCustomizer, and a library that needs its own instance registers it under a clear qualified name, like paymentsRestClient.

Third, a registry lists every shared bean type, its owner, how others may extend it and which names are taken, so disputes are settled once.

Fourth, a compatibility build pulls the most used starters into one sample application and asserts things like exactly one ObjectMapper and that the shared builder carries every starter's interceptors; every starter release must pass it before publishing.

I would publish the rules on one page with reasons and examples, review new starters against a short checklist, and add ArchUnit checks for things like @Primary in library code. I would bring existing starters in line over an agreed period and measure success by startup-conflict incidents falling to near zero.

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 "Internal starters from different platform teams keep conflicting over beans of the same...": https://scrivio-interview-library.netlify.app/spring-boot/dependency-injection/e43d0e669d/