中文博客

Spring Boot依赖面试必答:Starter、BOM与排除冲突

2026年5月10日19 分钟阅读
Spring Boot依赖面试必答:Starter、BOM与排除冲突

掌握Spring Boot依赖面试核心:Starter作用、BOM版本管理、父POM区别与依赖排除,快速说清机制与排查思路,面试更稳更有说服力。

Most candidates preparing for a Spring Boot interview can rattle off `spring-boot-starter-web` and `spring-boot-starter-data-jpa` without hesitation. The Spring Boot dependencies interview question that actually separates candidates isn't "name a starter" — it's "what does that starter do to your classpath, and what happens when two starters pull in conflicting versions of the same library?" That's where the memorized answers run out.

This guide is for candidates who know the starter names but need to explain the mechanics: what starters actually bundle, how dependency management keeps versions aligned, what the BOM and parent POM are really doing, and how to describe an exclusion without waving your hands. If you can answer those questions in plain English, you can handle most Spring Boot dependency questions in a technical screen.

Why Interviewers Stop Caring About Starter Names After the First Minute

The memorized answer problem

The pattern is predictable. An interviewer asks "how does Spring Boot handle dependencies?" and the candidate says "you add starters to your pom.xml and Spring Boot takes care of the rest." That answer isn't wrong, but it's the answer of someone who has read a getting-started tutorial, not someone who has debugged a classpath conflict at 11pm before a release.

The problem isn't that the candidate doesn't know the starter names. It's that the answer collapses the moment any follow-up arrives. "What does `spring-boot-starter-web` actually pull in?" "Why didn't you specify a version for Jackson?" "What happened when you had two starters that needed different versions of the same logging library?" If the answer to all three is a pause followed by "Spring Boot handles that automatically," the interview is effectively over.

This is the memorized-answer failure mode in a Spring Boot dependencies interview: the candidate knows the vocabulary but not the reasoning behind it.

What a real interview answer has to prove

The bar isn't deep framework internals. It's three things: the candidate understands how dependency assembly works (starters are curated sets of artifacts, not magic), they understand version alignment (something has to decide which version of Jackson lands on the classpath, and that something is the BOM), and they understand tradeoffs (adding a starter has transitive consequences, and exclusions are how you manage the ones you don't want).

Spring's official documentation on starters describes them explicitly as "a set of convenient dependency descriptors." That phrasing matters in an interview because it tells the interviewer you understand the mechanism, not just the shortcut. According to SHRM research on technical screening, interviewers consistently rate "ability to explain the why behind a tool choice" higher than factual recall — and dependency management is exactly the kind of topic where that distinction shows up.

Treat Spring Boot Starters Like Dependency Descriptors, Not Magic Packages

What starters actually bundle

A starter is a curated list of Maven dependencies grouped around a specific job. There's no magic at the starter level — it's a pom file that declares a set of compatible libraries so you don't have to assemble them by hand and guess whether the versions work together. The starter for web pulls in what you need to build a web application. The starter for JPA pulls in what you need to talk to a relational database. The point is consistency: every project using the same starter gets the same dependency graph, which makes version drift across a team much harder.

The word "curated" is doing real work here. The Spring Boot team maintains these starters and tests the combinations. When you add `spring-boot-starter-web`, you're not just getting Spring MVC — you're getting a tested combination of Spring MVC, Jackson, Tomcat (the embedded server), and validation support. None of that is magic. It's just a list someone else maintained so you didn't have to.

What this looks like in practice

A `pom.xml` with two starters looks like this:

No versions. No Jackson artifact. No Hibernate artifact. No Tomcat artifact. In a screen, the interviewer-safe explanation is: "Each starter is a dependency descriptor — a pom that lists the artifacts needed for that job. `starter-web` brings in Spring MVC, Jackson for JSON serialization, and embedded Tomcat. `starter-data-jpa` brings in Spring Data JPA, Hibernate as the default JPA provider, and JDBC support. I don't specify versions because those are managed by the BOM."

That last sentence is the pivot to the next topic, and it's the part most candidates skip.

Dependency Management Is the Part That Saves You From Version Chaos

Why normal Maven declarations are not enough

In a plain Maven project, every dependency declaration either specifies a version or inherits one from a parent. If you have ten dependencies and they each pull in Jackson transitively, you might end up with three different Jackson versions on the effective classpath, and Maven's nearest-wins resolution strategy picks one — not necessarily the one you wanted. The result is version drift: inconsistent behavior across modules, mysterious `NoSuchMethodError` exceptions, and debugging sessions that take hours because the classpath looks fine on the surface.

Spring Boot dependency management solves this by centralizing compatible versions in one place. When you use Boot's managed dependencies, you don't specify versions for the artifacts the BOM knows about. The BOM has already decided which version of Jackson works with which version of Spring, and that decision is consistent across every dependency that uses it. This is the structural fix that plain Maven declarations don't provide.

What this looks like in practice

When you add `spring-boot-starter-web` without a version, Maven resolves the version through the BOM. The effective pom shows something like:

You didn't declare that version. The BOM did. In an interview, the clean explanation is: "The BOM is a bill of materials — a pom file that defines a curated set of dependency versions. When I inherit from `spring-boot-starter-parent` or import the BOM directly, those versions are applied to any dependency I declare without a version. I'm trusting the Spring Boot team's compatibility testing rather than assembling versions myself."

That answer demonstrates understanding of the mechanism, not just the outcome.

What the BOM and starter parent are really doing

Both `spring-boot-starter-parent` and the Spring Boot BOM (`spring-boot-dependencies`) solve the same class of problem from different angles. The BOM is the version catalog — it defines compatible versions for hundreds of libraries. The parent POM imports the BOM and also adds plugin configuration, encoding defaults, and compiler settings. If your project already has a corporate parent POM, you can't use `spring-boot-starter-parent` as the parent, so you import the BOM directly in the `<dependencyManagement>` section instead. Same version alignment, less boilerplate inheritance.

Show the Parent POM, the BOM, and the Transitive Dependencies Together

How spring boot starter parent changes the default setup

Adding `spring-boot-starter-parent` as your project's parent gives you three things immediately: the BOM's managed versions, sensible Maven plugin defaults (compiler version, resource filtering, test configuration), and less boilerplate in every module. The tradeoff is that you've used your one parent slot. Teams with a corporate parent POM import the BOM directly instead — same version alignment, but they manage the plugin configuration themselves.

What this looks like in practice

A minimal `pom.xml` using the parent:

Running `mvn dependency:tree` on this project shows the transitive dependencies arriving without any explicit declaration:

None of those artifacts were declared. They came along because the starters listed them.

Why transitive dependencies matter in an interview answer

This is the part interviewers are actually listening for. When you add `spring-boot-starter-web`, you're not adding one artifact — you're adding a dependency graph. If another starter in your project pulls in a different version of `jackson-databind`, you have a conflict. If you don't understand that the conflict came from a transitive dependency, you can't fix it. Candidates who understand this say "I ran the dependency tree to find where the conflict was coming from." Candidates who don't say "I added an exclusion and it worked." The second answer doesn't prove understanding — it proves luck.

Explain the Starters Interviewers Actually Expect You To Know

Web, JPA, security, test, and actuator are the core five

These five starters come up in almost every backend screen, and knowing them at the "what does it bring in and why would I use it" level is the minimum bar.

`spring-boot-starter-web` is for building REST APIs and web applications. It brings in Spring MVC, Jackson, embedded Tomcat, and validation support. Don't claim it handles database access — that's a different starter.

`spring-boot-starter-data-jpa` is for relational database access using JPA. It brings in Spring Data JPA, Hibernate, and JDBC support. The interviewer-safe note: Hibernate is the default JPA provider, but it can be swapped.

`spring-boot-starter-security` is for authentication and authorization. It brings in Spring Security and configures a default security filter chain. Candidates often get this wrong by claiming it "secures your app automatically" — it sets up the infrastructure, but the configuration is your responsibility.

`spring-boot-starter-test` is for testing. It brings in JUnit 5, Mockito, AssertJ, and Spring's test utilities. It's scoped to test by default, so it doesn't land in your production artifact.

`spring-boot-starter-actuator` is for production monitoring. It brings in endpoints for health checks, metrics, and environment information. In a production service, this is not optional — it's how you know the app is alive.

What this looks like in practice

In a simple CRUD API, you'd typically use `starter-web`, `starter-data-jpa`, and `starter-test`. Add `starter-actuator` and `starter-security` once the service is moving toward production. The starters you choose define the dependency graph; the auto-configuration layer reads that graph and wires up beans accordingly. The starters are the input. The wired application context is the output.

Use Exclusions to Fix Conflict, Not to Sound Clever

Why conflicts show up in the first place

Transitive dependencies are the source of almost every dependency conflict in a Spring Boot project. Two starters can both pull in the same library at different versions. Maven's nearest-wins resolution picks one, but "nearest" doesn't mean "correct." The result is often a version that satisfies one starter but breaks the other — and the failure shows up at runtime as a `ClassNotFoundException` or `NoSuchMethodError`, not at compile time.

The clean fix is an exclusion: remove the bad version from the starter that's pulling it in transitively, then declare the version you actually want at the top level.

What this looks like in practice

A common conflict scenario: `spring-boot-starter-web` and a third-party library both pull in `commons-logging`, but at different versions. The fix:

After the exclusion, running `mvn dependency:tree` confirms the artifact is gone from that branch of the graph. If the app still needs the library, you declare it directly at the version you want. If it doesn't, you leave it out.

How to describe the fix without sounding vague

The interview-safe explanation is three steps: "I ran the dependency tree to find which artifact was causing the conflict and where it was coming from. I added an exclusion to the dependency that was pulling in the wrong version transitively. Then I checked whether the app still needed that library — if it did, I declared it directly at the correct version." That answer demonstrates you understand the mechanism. "I just excluded it" does not.

Maven's official documentation on dependency exclusions covers the syntax and the reasoning. The Spring Boot reference docs also address known exclusion patterns for logging libraries specifically.

Stop Mixing Up Auto Configuration and Dependency Management

They solve different problems

This is the most common conceptual error in Spring Boot dependency interviews, and it's worth being direct about: dependency management decides what gets on the classpath, while auto-configuration decides what Spring Boot wires up from what's already there. They are separate mechanisms. Conflating them is a red flag for an interviewer because it suggests the candidate doesn't understand how Boot actually works — they just know it works.

Dependency management happens at build time. The BOM and starters determine which artifacts land in your compiled artifact. Auto-configuration happens at application startup. Spring Boot scans the classpath, finds the libraries that are present, and creates beans based on `@Conditional` annotations that check for their existence.

What this looks like in practice

Adding `spring-boot-starter-data-jpa` puts Hibernate and Spring Data JPA on the classpath. That's dependency management. When the application starts and Spring Boot finds Hibernate on the classpath, it auto-configures a `DataSource`, a `LocalContainerEntityManagerFactoryBean`, and a `JpaTransactionManager` — without you writing any of that configuration. That's auto-configuration.

The clean interview answer: "Dependency management is a build-time concern — it controls what's on the classpath. Auto-configuration is a runtime concern — it controls what Spring wires up from what's on the classpath. Adding a starter doesn't configure anything by itself. It just makes the libraries available so auto-configuration can do its job."

Spring Boot's auto-configuration documentation makes this distinction explicit and is worth reading before any technical screen.

Answer the Interview Questions Without Falling Into Buzzword Soup

The short answers candidates should be ready to give

The questions below come up in almost every Spring Boot dependencies interview. Having a clean, one-paragraph answer for each one is the minimum preparation.

What is a Spring Boot starter? "A starter is a dependency descriptor — a pom file that lists a curated set of compatible libraries for a specific job. When I add `spring-boot-starter-web`, I'm not adding magic; I'm adding a tested combination of Spring MVC, Jackson, and embedded Tomcat. The point is that someone else already figured out which versions work together."

What does Spring Boot dependency management do? "It centralizes version decisions in the BOM. When I declare a dependency without a version, the BOM supplies the compatible version. That prevents version drift across the project and means I'm not manually reconciling library versions."

Why does `spring-boot-starter-parent` matter? "It inherits the BOM, which gives me managed versions for hundreds of libraries. It also configures sensible Maven plugin defaults so I don't have to repeat that configuration in every project. If I can't use it as a parent, I import the BOM directly in `<dependencyManagement>` instead."

How do exclusions work? "I run the dependency tree to find the conflicting artifact and which dependency is pulling it in transitively. I add an exclusion to that dependency to remove the bad version, then declare the correct version directly if the app still needs it."

What this looks like in practice

The difference between a memorized answer and a real one shows up immediately when the follow-up arrives. "What does `spring-boot-starter-web` bring in?" — a memorized answer says "web dependencies." A real answer says "Spring MVC, Jackson for JSON serialization, embedded Tomcat, and the validation API." One of those answers tells the interviewer you've actually looked at the dependency tree. The other tells them you've read a summary.

Recruiters Can Spot Real Understanding Faster Than Candidates Think

What a strong answer sounds like to a recruiter

Recruiters and technical screeners doing backend interviews aren't looking for encyclopedic knowledge. They're applying a simple three-part test: can the candidate define the concept, name the consequence, and explain one tradeoff? For Spring Boot dependencies, that means: what is a starter (definition), what does it do to the classpath (consequence), and what happens when two starters conflict (tradeoff). A candidate who can do all three in two minutes of conversation passes the dependency section of the screen.

What this looks like in practice

The red flags are consistent. Reciting starter names with no explanation of what they pull in. Using "Spring Boot handles that automatically" as the answer to every follow-up. Describing exclusions as something you "just add" without explaining how you identified the conflict. Mixing up auto-configuration and dependency management in the same sentence.

The positive signal is equally consistent. The candidate runs the dependency tree before guessing. They can name what a specific starter brings in without looking it up. They describe a conflict they've actually encountered and explain how they resolved it. They know the difference between the BOM and the parent POM and can explain when you'd use one without the other. That combination — definition, consequence, tradeoff, and a real example — is what a strong answer sounds like to anyone evaluating backend candidates.

FAQ

Q: What are Spring Boot starter dependencies, and how do they differ from regular Maven dependencies?

A starter is a curated pom file that groups a set of compatible library dependencies around a specific job — web, persistence, security, testing. A regular Maven dependency is a single artifact you declare yourself, with a version you manage. The difference is that starters give you a tested combination of libraries without requiring you to assemble or version them manually, while regular dependencies put that responsibility on you.

Q: What does Spring Boot dependency management actually do behind the scenes?

It supplies compatible versions for every library listed in the BOM. When you declare a dependency without a version in a Boot project, Maven looks up the version in the managed-versions section of the effective pom — which comes from the BOM. This prevents version drift across the project and means you're relying on the Spring Boot team's compatibility testing rather than assembling versions yourself.

Q: How does spring-boot-starter-parent help with version alignment and transitive dependencies?

The parent POM inherits the Spring Boot BOM, which defines managed versions for hundreds of libraries. Any dependency you declare without a version gets that managed version applied automatically. Transitive dependencies pulled in by starters also use the BOM's versions unless something overrides them, which is why the classpath stays consistent without manual version declarations.

Q: Which starters should a candidate be able to explain in an interview, and what does each one bring in?

The five that come up most often are `starter-web` (Spring MVC, Jackson, embedded Tomcat), `starter-data-jpa` (Hibernate, Spring Data JPA, JDBC), `starter-security` (Spring Security, default filter chain), `starter-test` (JUnit 5, Mockito, AssertJ), and `starter-actuator` (health, metrics, and environment endpoints). Knowing what each one brings in at a high level — not every transitive artifact, but the key ones — is the minimum bar.

Q: How do exclusions work when a dependency conflict appears, and how should you describe that clearly?

Run `mvn dependency:tree` to find the conflicting artifact and which dependency is pulling it in transitively. Add an exclusion to that dependency in your pom to remove the bad version from that branch of the graph. If the application still needs the library, declare it directly at the correct version. The interview-safe version of this answer names all three steps: identify, exclude, replace if needed.

Q: What is the difference between auto-configuration and dependency management in Spring Boot?

Dependency management is a build-time concern — it controls which artifacts land on the classpath. Auto-configuration is a runtime concern — it controls which beans Spring creates based on what's on the classpath. Adding a starter puts libraries on the classpath. Auto-configuration reads the classpath at startup and wires up beans conditionally. They are separate mechanisms with separate responsibilities.

Q: What are the most common mistakes candidates make when answering Spring Boot dependency questions?

Three mistakes come up consistently: conflating auto-configuration with dependency management, describing exclusions without explaining how they identified the conflict, and using "Spring Boot handles that automatically" as the answer to follow-up questions. All three signal that the candidate knows the vocabulary but hasn't worked through the mechanics.

Q: How can a recruiter tell whether a candidate truly understands Spring Boot dependencies versus just memorized starter names?

Ask one follow-up: "What does that starter actually bring in?" A candidate who understands the stack can name the key transitive dependencies without looking them up. A candidate who memorized starter names can't. The second signal is whether they can describe a real conflict they've resolved — the dependency tree, the exclusion, the fix — rather than describing the concept in the abstract.

How Verve AI Can Help You Prepare for Your Interview With Spring Boot Dependencies

The structural problem with preparing for a Spring Boot dependencies interview is that the content is easy to read and hard to reproduce under pressure. You can understand the BOM perfectly on paper and still give a rambling, circular answer when an interviewer asks "what's the difference between dependency management and auto-configuration?" in a live screen. Reading is passive. Answering out loud, in real time, to a follow-up you didn't anticipate — that's a different skill entirely.

Verve AI Interview Copilot is built for exactly that gap. It listens in real-time to your answers during practice sessions and responds to what you actually said — not a canned prompt. If you give the memorized version of a starter explanation and skip the transitive dependency detail, Verve AI Interview Copilot surfaces the follow-up that exposes the gap, the same way a real interviewer would. It suggests answers live based on the specific question and your specific response, so the feedback is calibrated to your actual answer, not a generic rubric. And it stays invisible while it does all of this — the desktop app is undetectable to screen share at the OS level, so you can practice in the same environment you'll perform in. For a topic like Spring Boot dependencies, where the real test is whether you can reconstruct the reasoning under pressure, that kind of live, responsive practice is the preparation that actually transfers.

Conclusion

The interview room version of Spring Boot dependency knowledge is simpler than it looks from the outside. If you can explain what a starter is and what it brings in, describe how the BOM keeps versions aligned, walk through a transitive dependency tree, and narrate a real exclusion fix in three steps — you can handle most of what a backend screen will throw at you on this topic. You don't need to memorize every artifact in the Spring ecosystem. You need to understand the mechanism well enough to reason through a question you haven't seen before.

Before your next interview, rehearse two things: one clean explanation of the starter-BOM-parent relationship in plain English, and one conflict story where you ran the dependency tree, found the problem, and fixed it with an exclusion. Those two answers, delivered without hesitation, will do more for your interview than a catalog of starter names ever will.

VA

Verve AI

内容