What is spring-boot-starter-parent and why do Spring Boot projects use it as their Maven parent?
answer
- Parent POM = curated defaults
- Extends spring-boot-dependencies BOM
- Versions + Java + UTF-8 + plugins
- repackage bound to package
- Everything overridable
basics
~20 sIt is a special Maven parent POM you inherit from. It sets sensible defaults for you: dependency versions, a Java version, UTF-8 encoding, and it configures the plugin that builds a runnable Spring Boot jar — so you write far less pom.xml.
solid answer
~40 sspring-boot-starter-parent is a curated Maven parent POM. By putting it in <parent>, your project inherits: (1) dependency version management (it itself extends spring-boot-dependencies, a big BOM, so you list dependencies without <version>); (2) a default Java compiler version via the java.version property; (3) UTF-8 source and resource encoding; (4) resource filtering with @...@ delimiters; and (5) pluginManagement that pre-configures common Maven plugins, including the spring-boot-maven-plugin with its repackage goal bound to the package phase so `mvn package` yields an executable fat jar. The net effect is a tiny, consistent pom.xml. You can override any inherited default (e.g. <java.version>21</java.version>) in your own properties.
code
kotlin · 20 lines// Minimal Maven pom via the parent (shown as XML in a comment for clarity):
//
// <parent>
// <groupId>org.springframework.boot</groupId>
// <artifactId>spring-boot-starter-parent</artifactId>
// <version>3.3.0</version>
// <relativePath/>
// </parent>
//
// <properties>
// <java.version>21</java.version> // override the inherited default
// </properties>
//
// <dependencies>
// <dependency>
// <groupId>org.springframework.boot</groupId>
// <artifactId>spring-boot-starter-web</artifactId>
// <!-- no <version>: managed by the inherited BOM -->
// </dependency>
// </dependencies>go deeper
Should know it's a parent POM giving defaults so pom.xml stays small, and that starters need no explicit version.
Should enumerate the concrete things inherited: BOM versions, java.version, UTF-8, plugin management, repackage wiring.
Should explain the parent→spring-boot-dependencies chain and the override model, plus the one-parent constraint.
Should frame it as centralized, overridable build governance and know when a corporate parent forces the BOM-import alternative.
## What it is `spring-boot-starter-parent` is a **Maven parent POM** published by the Spring Boot team. In Maven, a project can declare a `<parent>` and inherit that parent's configuration (properties, dependency management, plugin management, build settings). Spring Boot ships this parent so a typical app's `pom.xml` can be very small. ```xml <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>3.3.0</version> <relativePath/> </parent> ``` ## What you inherit 1. **Dependency version management.** `spring-boot-starter-parent` itself has `<parent>` = `spring-boot-dependencies`, which is a **BOM** (Bill of Materials): a POM whose `<dependencyManagement>` pins the versions of hundreds of libraries (Spring, Jackson, Hibernate, JUnit, etc.). Because you inherit that, you can declare `spring-boot-starter-web` with **no `<version>`** — the version comes from the managed list. This prevents version conflicts across the ecosystem. 2. **Java version.** The parent defines a `java.version` property (a default). Setting `<java.version>21</java.version>` in your `<properties>` feeds Maven's compiler configuration (`maven.compiler.release`/`source`/`target`), telling `maven-compiler-plugin` which JDK level to compile for. 3. **Encoding.** It sets `project.build.sourceEncoding` and `project.reporting.outputEncoding` to **UTF-8**, so builds are reproducible across machines regardless of the OS default charset. 4. **Resource filtering with `@...@` delimiters.** More on this in a dedicated question — it lets you substitute Maven properties like `@project.version@` into files such as `application.properties` without clashing with Spring's own `${...}` placeholders. 5. **`pluginManagement`.** The parent pre-configures versions and sensible settings for common build plugins (compiler, surefire, failsafe, jar, war, resources, shade, etc.) and — crucially — the **`spring-boot-maven-plugin`**, including an execution that binds its **`repackage`** goal to the `package` phase. So `mvn package` produces the executable, self-contained ('fat') jar. ## Override model Everything is a **default you can override**. Redefine a property (`java.version`, `spring-boot.version`), add plugin config in your own `<build>`, or exclude a managed dependency. Because these live in a parent, changes are centralized and consistent. ## Gotchas - `<relativePath/>` (empty) tells Maven **not** to look for the parent on the local filesystem and to resolve it from the repository — important because this parent is a published artifact, not a sibling module. - You can only have **one** Maven parent. If your organization already mandates a corporate parent POM, you **cannot** also use `spring-boot-starter-parent` — that's the classic reason to switch to the `spring-boot-dependencies` BOM as an *import* instead (covered separately). - Inheriting the parent does **not** add any dependencies to your build — it only *manages* them. You still declare the starters you want.
- Does inheriting the parent pull in any runtime dependencies by itself?No. It only manages versions and plugin config. You still explicitly declare the starters/dependencies you need; the parent just supplies their versions and build wiring.
- What does the empty <relativePath/> do?It disables Maven's default behavior of searching the local filesystem (../pom.xml) for the parent, forcing resolution from the repository since the parent is a published artifact.
saying these in an interview costs you the question
- Thinking the parent adds Spring dependencies to the classpath automatically
- Believing you must specify <version> on each starter even with the parent
- Confusing the parent with the application's own @SpringBootApplication class