Week 3 Day 2 — Spring Boot Starters and Dependency Management
Goal
Today I want to understand Spring Boot starters and dependency management.
Main questions:
- What is a Spring Boot starter?
- Why do starters exist?
- What is dependency management?
- What problem does Spring Boot dependency management solve?
- What is the difference between a starter and auto-configuration?
- What is a transitive dependency?
- Why should I usually not specify versions manually?
- What is the Spring Boot parent POM?
- What is the Spring Boot BOM?
- How does this work in Gradle?
- What are common starter dependencies?
- What are common exam traps?
1. Quick Review from Week 3 Day 1
In Day 1, I learned:
- Spring Boot makes Spring applications easier to configure, run, and deploy.
@SpringBootApplicationincludes:
@Configuration
@EnableAutoConfiguration
@ComponentScan
@EnableAutoConfigurationenables Spring Boot auto-configuration.- Auto-configuration is conditional.
- Starters bring dependencies.
- Auto-configuration configures beans based on those dependencies.
Memory sentence:
Starters bring libraries.
Auto-configuration configures them.
Today I go deeper into starters and dependency management.
2. What Is a Spring Boot Starter?
A Spring Boot starter is a dependency bundle.
It groups common dependencies for a specific feature.
Example:
implementation("org.springframework.boot:spring-boot-starter-web")
This one dependency brings the common libraries needed for a Spring MVC web application.
Simple definition:
A Spring Boot starter is a convenient dependency that brings a set of related libraries for a common application feature.
3. Why Do Starters Exist?
Without starters, I would need to manually choose many dependencies.
For a web application, I might need:
Spring MVC
Jackson JSON support
embedded Tomcat
logging
validation if needed
Spring core dependencies
Instead of adding many dependencies manually, I add:
implementation("org.springframework.boot:spring-boot-starter-web")
Spring Boot gives a sensible dependency set.
Memory sentence:
Starters reduce dependency boilerplate.
4. Starter Does Not Mean Auto-Configuration
Important distinction:
Starter = dependency bundle
Auto-configuration = bean configuration mechanism
Example:
implementation("org.springframework.boot:spring-boot-starter-web")
The starter adds web libraries to the classpath.
Then auto-configuration sees those libraries and configures:
embedded Tomcat
Spring MVC
DispatcherServlet
HTTP message converters
JSON serialization
The starter itself does not “start” the app.
It just brings dependencies.
5. Starter vs Auto-Configuration
| Topic | Starter | Auto-Configuration |
|---|---|---|
| What it is | dependency bundle | automatic bean setup |
| Works through | Maven/Gradle dependencies | Spring Boot conditions |
| Example | spring-boot-starter-web | WebMvcAutoConfiguration |
| Main job | brings libraries | configures beans |
| Based on | dependency metadata | classpath, properties, beans |
Memory sentence:
Starter puts tools in the box. Auto-configuration decides how to use them.
6. Example: Web Starter
Gradle:
implementation("org.springframework.boot:spring-boot-starter-web")
This gives me a traditional servlet-based web application.
Common things it brings:
Spring MVC
embedded Tomcat
Jackson JSON support
Spring Boot core starter
logging support
Then I can write:
@RestController
@RequestMapping("/api/hello")
public class HelloController {
@GetMapping
public String hello() {
return "Hello";
}
}
Spring Boot can expose this endpoint because the web dependencies and web auto-configuration are present.
7. Important: Validation Is Usually Separate
Do not assume validation is always included with the web starter.
For Bean Validation annotations like:
@NotBlank
@Email
@Valid
you normally add:
implementation("org.springframework.boot:spring-boot-starter-validation")
Example DTO:
public record CreateUserRequest(
@NotBlank String name,
@Email String email
) {
}
Controller:
@PostMapping
public void createUser(@Valid @RequestBody CreateUserRequest request) {
}
Memory sentence:
For validation, use
spring-boot-starter-validation.
8. Common Spring Boot Starters
Common starters:
spring-boot-starter
spring-boot-starter-web
spring-boot-starter-webflux
spring-boot-starter-data-jpa
spring-boot-starter-data-mongodb
spring-boot-starter-security
spring-boot-starter-validation
spring-boot-starter-test
spring-boot-starter-actuator
spring-boot-starter-mail
spring-boot-starter-cache
spring-boot-starter-quartz
You do not need to memorize every starter.
But you should understand the pattern.
9. spring-boot-starter
This is the core starter.
It includes basic Spring Boot dependencies such as:
Spring Boot core
Spring Framework core support
logging
auto-configuration support
YAML/property support through Boot infrastructure
Most other starters depend on it.
Example:
implementation("org.springframework.boot:spring-boot-starter")
Use it for non-web apps, workers, CLI apps, or background services.
10. spring-boot-starter-web
Use for traditional REST APIs and Spring MVC apps.
implementation("org.springframework.boot:spring-boot-starter-web")
Typical use cases:
REST API
MVC web application
JSON HTTP endpoints
Servlet-based web app
Common stack:
Spring MVC
embedded Tomcat
Jackson
11. spring-boot-starter-webflux
Use for reactive web applications.
implementation("org.springframework.boot:spring-boot-starter-webflux")
Typical use cases:
reactive HTTP APIs
non-blocking web clients
high-concurrency reactive systems
Usually based on:
Spring WebFlux
Project Reactor
Reactor Netty by default
Important:
Do not randomly mix
spring-boot-starter-webandspring-boot-starter-webfluxunless you understand the application type.
For most normal REST APIs, use:
spring-boot-starter-web
12. spring-boot-starter-data-jpa
Use for relational database access with JPA.
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
Commonly used with:
PostgreSQL
MySQL
MariaDB
H2
It brings support for:
Spring Data JPA
Hibernate
JPA repositories
transaction infrastructure
You still need a database driver.
Example PostgreSQL driver:
runtimeOnly("org.postgresql:postgresql")
Memory sentence:
JPA starter gives JPA support, but I still need the database driver.
13. Example: JPA Dependencies
dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
runtimeOnly("org.postgresql:postgresql")
}
Configuration:
spring:
datasource:
url: jdbc:postgresql://localhost:5432/app
username: postgres
password: postgres
Without database config or embedded database, the app may fail because Boot tries to configure a DataSource.
14. spring-boot-starter-security
Use for Spring Security.
implementation("org.springframework.boot:spring-boot-starter-security")
Important effect:
Adding the security starter changes application behavior.
For a web app, Spring Boot may secure endpoints by default.
You often need to define a security configuration:
@Configuration
public class SecurityConfig {
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
return http
.authorizeHttpRequests(auth -> auth
.anyRequest().authenticated()
)
.build();
}
}
Exam trap:
Some starters do not just add libraries; they also trigger auto-configuration that changes behavior.
15. spring-boot-starter-actuator
Use for production monitoring endpoints.
implementation("org.springframework.boot:spring-boot-starter-actuator")
Common Actuator endpoints:
/actuator/health
/actuator/info
/actuator/metrics
/actuator/beans
/actuator/conditions
/actuator/configprops
Example config:
management:
endpoints:
web:
exposure:
include: health,info,metrics
Memory sentence:
Actuator adds production-ready monitoring and management endpoints.
16. spring-boot-starter-test
Use for testing.
testImplementation("org.springframework.boot:spring-boot-starter-test")
It commonly brings testing libraries such as:
JUnit Jupiter
Spring Test
AssertJ
Mockito
Hamcrest
JSONassert
JsonPath
Then I can write:
@SpringBootTest
class ApplicationTest {
@Test
void contextLoads() {
}
}
17. What Is a Transitive Dependency?
A transitive dependency is a dependency brought by another dependency.
Example:
I add:
implementation("org.springframework.boot:spring-boot-starter-web")
This starter brings other dependencies.
I did not manually add all of them.
They are transitive dependencies.
Simple definition:
A transitive dependency is a dependency that comes indirectly through another dependency.
18. Example of Transitive Dependencies
I add one dependency:
implementation("org.springframework.boot:spring-boot-starter-web")
Maven/Gradle resolves many dependencies, for example:
spring-web
spring-webmvc
spring-boot-starter-tomcat
spring-boot-starter-json
spring-boot-starter
I do not need to manually add every library.
This is the convenience of starters.
19. The Problem with Manual Dependency Versions
Without Spring Boot dependency management, I might write:
implementation("org.springframework:spring-webmvc:6.x.x")
implementation("com.fasterxml.jackson.core:jackson-databind:2.x.x")
implementation("org.apache.tomcat.embed:tomcat-embed-core:10.x.x")
implementation("org.hibernate.orm:hibernate-core:6.x.x")
Problem:
Which versions work together?
Which version of Jackson is compatible?
Which Hibernate version matches Spring Boot?
Which Tomcat version is safe?
Manual version management can become painful.
20. What Is Dependency Management?
Dependency management means:
A build system uses a known set of dependency versions so libraries work well together.
Spring Boot provides dependency management for many common libraries.
So I can write:
implementation("org.springframework.boot:spring-boot-starter-web")
runtimeOnly("org.postgresql:postgresql")
without manually specifying versions for Boot-managed dependencies.
Memory sentence:
Spring Boot manages compatible dependency versions for me.
21. Why Version Alignment Matters
Libraries depend on other libraries.
If versions do not match, I may get runtime errors such as:
ClassNotFoundException
NoSuchMethodError
NoClassDefFoundError
Bean creation errors
serialization errors
database integration errors
Example problem:
Spring expects a newer method from a library.
But the classpath contains an older version.
App fails at runtime.
Dependency management reduces this risk.
22. Maven: Spring Boot Parent POM
In Maven, many projects use:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>...</version>
</parent>
The parent POM provides:
dependency management
plugin management
default Java settings
resource filtering support
sensible Maven defaults
Then dependencies can omit versions:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
The parent manages the version.
23. Maven Without Parent: BOM
Sometimes a project cannot use the Spring Boot parent.
Then it can import the Spring Boot BOM.
BOM means:
Bill of Materials
It defines dependency versions.
Maven example:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>...</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Then dependencies can still omit versions.
Memory sentence:
The Spring Boot BOM manages dependency versions without using the Boot parent POM.
24. Parent POM vs BOM
| Topic | Parent POM | BOM |
|---|---|---|
| Maven parent | yes | no |
| Dependency versions | yes | yes |
| Plugin management | yes | no, not the same |
| Useful when | normal Boot Maven app | project already has another parent |
| Artifact | spring-boot-starter-parent | spring-boot-dependencies |
25. Gradle: Spring Boot Plugin
In Gradle, a Spring Boot project often uses:
plugins {
id("org.springframework.boot") version "..."
id("io.spring.dependency-management") version "..."
java
}
Or Kotlin DSL:
plugins {
id("org.springframework.boot") version "..."
id("io.spring.dependency-management") version "..."
kotlin("jvm") version "..."
kotlin("plugin.spring") version "..."
}
The Spring Boot Gradle plugin helps with:
packaging executable jars
Boot tasks
dependency management integration
running the app
layered jars support
26. Gradle Dependencies Without Versions
Typical Gradle dependencies:
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
runtimeOnly("org.postgresql:postgresql")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
Notice:
No versions are specified for these dependencies.
Spring Boot dependency management provides compatible versions.
27. Should I Specify Versions Manually?
Usually, for dependencies managed by Spring Boot:
No.
Prefer:
implementation("org.springframework.boot:spring-boot-starter-web")
Avoid:
implementation("org.springframework.boot:spring-boot-starter-web:3.x.x")
in a Boot project that already applies Boot dependency management.
For third-party dependencies not managed by Boot, you may need to specify a version.
Memory sentence:
Let Spring Boot manage versions when possible.
28. What If I Need a Different Version?
Sometimes you need to override a managed version.
Example reasons:
security patch
bug fix
company standard
compatibility issue
But be careful.
Overriding managed versions can break compatibility.
Best practice:
Override only when necessary.
Understand the compatibility impact.
Prefer upgrading Spring Boot version when possible.
29. Common Mistake: Mixing Spring Boot Versions
Bad idea:
implementation("org.springframework.boot:spring-boot-starter-web:3.3.0")
implementation("org.springframework.boot:spring-boot-starter-data-jpa:3.1.0")
This can cause dependency conflicts.
Better:
plugins {
id("org.springframework.boot") version "3.x.x"
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
}
Use one Spring Boot version to manage the dependency set.
30. Common Mistake: Adding Both Web and WebFlux
Example:
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-webflux")
This may be valid in special cases, but it can confuse beginners.
Most normal REST APIs should use:
spring-boot-starter-web
Reactive apps should use:
spring-boot-starter-webflux
Memory sentence:
Choose the web stack intentionally.
31. Common Mistake: Adding JPA Starter Without Database
Example:
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
If no datasource is configured and no embedded database is available, Boot may fail to start.
Why?
Because the JPA starter triggers database-related auto-configuration.
Fix options:
configure datasource
add database driver
use embedded database for tests
remove JPA starter if not needed
exclude DataSourceAutoConfiguration if truly necessary
32. Common Mistake: Forgetting Runtime Driver
JPA starter does not automatically know which database you use.
For PostgreSQL:
runtimeOnly("org.postgresql:postgresql")
For MySQL:
runtimeOnly("com.mysql:mysql-connector-j")
For MariaDB:
runtimeOnly("org.mariadb.jdbc:mariadb-java-client")
Memory sentence:
Add the database driver for your database.
33. Common Mistake: Forgetting Validation Starter
If I use:
@NotBlank
@Valid
but validation does not work or annotations are missing, I may need:
implementation("org.springframework.boot:spring-boot-starter-validation")
This is common in REST APIs.
34. Common Mistake: Too Many Dependencies
Bad:
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework:spring-web")
implementation("org.springframework:spring-webmvc")
implementation("com.fasterxml.jackson.core:jackson-databind")
Usually unnecessary.
The web starter already brings common web dependencies.
Too many manual dependencies can create version conflicts.
Memory sentence:
Start with starters. Add specific dependencies only when needed.
35. Dependency Scopes / Configurations
In Gradle, common configurations:
implementation
runtimeOnly
compileOnly
annotationProcessor
testImplementation
testRuntimeOnly
developmentOnly
Examples:
implementation("org.springframework.boot:spring-boot-starter-web")
runtimeOnly("org.postgresql:postgresql")
testImplementation("org.springframework.boot:spring-boot-starter-test")
developmentOnly("org.springframework.boot:spring-boot-devtools")
36. implementation
Use implementation for dependencies needed to compile and run the app.
Example:
implementation("org.springframework.boot:spring-boot-starter-web")
Your code uses classes from this dependency.
37. runtimeOnly
Use runtimeOnly for dependencies needed only at runtime.
Example:
runtimeOnly("org.postgresql:postgresql")
Your app usually does not directly compile against PostgreSQL driver classes.
The driver is needed at runtime by JDBC.
38. testImplementation
Use testImplementation for test dependencies.
Example:
testImplementation("org.springframework.boot:spring-boot-starter-test")
These dependencies are available for tests, not main production code.
39. developmentOnly
Use developmentOnly for development-only tools.
Example:
developmentOnly("org.springframework.boot:spring-boot-devtools")
Devtools can help with:
automatic restart
development convenience
It should not be needed in production.
40. Starter Naming Pattern
Most official Spring Boot starters follow:
spring-boot-starter-*
Examples:
spring-boot-starter-web
spring-boot-starter-data-jpa
spring-boot-starter-security
spring-boot-starter-actuator
Some third-party libraries also provide their own starters.
But for certification, focus on official Boot starters and the concept.
41. How to Inspect Dependencies
Useful commands:
Gradle:
./gradlew dependencies
Specific dependency insight:
./gradlew dependencyInsight --dependency jackson-databind
Maven:
mvn dependency:tree
These commands help answer:
Why is this dependency here?
Which version is used?
Which dependency brought it?
Are there conflicts?
42. How Starters Connect to Auto-Configuration
Example:
I add:
implementation("org.springframework.boot:spring-boot-starter-actuator")
This puts Actuator classes on the classpath.
Auto-configuration sees Actuator classes.
Then Boot configures Actuator endpoints.
If I add:
management:
endpoints:
web:
exposure:
include: health,info
Boot uses properties to decide which endpoints are exposed.
Flow:
starter dependency
↓
classes on classpath
↓
auto-configuration conditions match
↓
beans are created
↓
properties customize behavior
43. Real Exam Question: Starter
Question:
What is a Spring Boot starter?
Answer:
A Spring Boot starter is a dependency bundle that brings together commonly used dependencies for a specific feature, such as web, JPA, security, testing, or Actuator.
44. Real Exam Question: Starter vs Auto-Configuration
Question:
What is the difference between a starter and auto-configuration?
Answer:
A starter brings dependencies onto the classpath. Auto-configuration sees those dependencies and configures Spring beans based on conditions, properties, and existing beans.
45. Real Exam Question: Transitive Dependency
Question:
What is a transitive dependency?
Answer:
A transitive dependency is a dependency that is brought indirectly by another dependency.
Example:
I add spring-boot-starter-web.
It brings spring-webmvc and embedded Tomcat.
Those are transitive dependencies.
46. Real Exam Question: Dependency Management
Question:
What problem does Spring Boot dependency management solve?
Answer:
It provides a compatible set of dependency versions so developers do not need to manually choose versions for common libraries. This reduces version conflicts and runtime compatibility problems.
47. Real Exam Question: Manual Versions
Question:
Should I usually specify versions for Spring Boot managed dependencies?
Answer:
No. In a Spring Boot project using Boot dependency management, I should usually omit versions for managed dependencies and let Spring Boot choose compatible versions.
48. Real Exam Question: BOM
Question:
What is a BOM?
Answer:
A BOM is a Bill of Materials. It defines a set of dependency versions. Spring Boot provides a BOM called spring-boot-dependencies that can manage dependency versions without using the Boot parent POM.
49. Real Exam Question: Parent POM
Question:
What does spring-boot-starter-parent provide in Maven?
Answer:
It provides dependency management, plugin management, and sensible Maven defaults for Spring Boot applications.
50. Real Exam Question: Database Driver
Question:
Does spring-boot-starter-data-jpa include the PostgreSQL driver automatically?
Answer:
No. The JPA starter provides JPA and Hibernate support, but I still need to add the database driver, such as org.postgresql:postgresql.
51. Real Exam Question: Security Starter
Question:
What can happen when I add spring-boot-starter-security to a web app?
Answer:
Spring Boot may apply Spring Security auto-configuration and secure the application by default. Endpoints may require authentication unless I configure security behavior.
52. Real Exam Question: Validation Starter
Question:
Which starter should I add for Bean Validation annotations such as @NotBlank and @Valid?
Answer:
Use:
spring-boot-starter-validation
53. Interview Answer
Question:
What are Spring Boot starters?
Good answer:
Spring Boot starters are dependency bundles that group common libraries for a specific feature. For example, spring-boot-starter-web brings the common dependencies for building a Spring MVC web application, while spring-boot-starter-data-jpa brings JPA and Hibernate support. Starters reduce dependency boilerplate and help developers start with a compatible set of libraries.
54. Interview Answer
Question:
What is the difference between starters and auto-configuration?
Good answer:
A starter brings dependencies onto the classpath. Auto-configuration looks at the classpath, application properties, existing beans, and conditions, then creates and configures beans automatically. For example, the web starter brings Spring MVC and Tomcat dependencies, and web auto-configuration configures DispatcherServlet, embedded Tomcat, and HTTP message converters.
55. Interview Answer
Question:
What is Spring Boot dependency management?
Good answer:
Spring Boot dependency management provides a curated set of compatible library versions. This means I can usually omit versions for dependencies managed by Spring Boot, and Boot will choose versions that work together. This reduces dependency conflicts, avoids runtime errors caused by incompatible libraries, and makes upgrades easier.
56. Interview Answer
Question:
Why should we avoid manually overriding dependency versions?
Good answer:
Manually overriding versions can break compatibility with the Spring Boot version and other managed dependencies. It can lead to runtime errors such as NoSuchMethodError, ClassNotFoundException, or bean creation failures. If a different version is needed, it should be done carefully, usually for a clear reason such as a security fix, and preferably by upgrading Spring Boot itself.
57. Interview Answer
Question:
What is the Spring Boot BOM?
Good answer:
The Spring Boot BOM, or Bill of Materials, is spring-boot-dependencies. It defines dependency versions for many common libraries used with Spring Boot. It is useful when a Maven project cannot use the Spring Boot parent POM but still wants Spring Boot’s dependency version management.
58. Tiny Code Practice
Gradle example:
plugins {
id("org.springframework.boot") version "3.x.x"
id("io.spring.dependency-management") version "1.x.x"
java
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
runtimeOnly("org.postgresql:postgresql")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
Questions:
- Which dependency creates a servlet web app?
- Which dependency enables Bean Validation support?
- Which dependency gives JPA support?
- Which dependency is the database driver?
- Why are versions omitted?
Answers:
spring-boot-starter-webspring-boot-starter-validationspring-boot-starter-data-jpaorg.postgresql:postgresql- Spring Boot dependency management provides compatible versions.
59. Tiny Bug Practice 1
Problem:
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
But no database driver is added.
Question:
What might happen?
Answer:
Spring Boot may try to configure JPA and a DataSource, but without a database driver or proper datasource configuration, the app may fail to start.
Fix:
runtimeOnly("org.postgresql:postgresql")
and configure datasource properties.
60. Tiny Bug Practice 2
Problem:
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework:spring-webmvc:some-manual-version")
implementation("com.fasterxml.jackson.core:jackson-databind:some-manual-version")
Question:
What is the problem?
Answer:
The web starter already brings common web dependencies. Adding manual versions can create dependency conflicts or compatibility problems. It is usually better to let Spring Boot manage these versions.
Practice Questions and Answers
Question 1
What is a Spring Boot starter?
Answer:
A Spring Boot starter is a dependency bundle that brings together common libraries for a specific feature, such as web, JPA, security, testing, or Actuator.
Question 2
Why do starters exist?
Answer:
Starters exist to reduce dependency boilerplate and provide a convenient, compatible set of libraries for common application features.
Question 3
What is the difference between a starter and auto-configuration?
Answer:
A starter brings dependencies onto the classpath. Auto-configuration configures beans based on those dependencies, properties, existing beans, and conditions.
Question 4
What is a transitive dependency?
Answer:
A transitive dependency is a dependency brought indirectly by another dependency.
Question 5
What does spring-boot-starter-web usually provide?
Answer:
spring-boot-starter-web usually provides Spring MVC, embedded Tomcat, Jackson JSON support, and web infrastructure dependencies.
Question 6
What does spring-boot-starter-data-jpa provide?
Answer:
spring-boot-starter-data-jpa provides Spring Data JPA, Hibernate, JPA repository support, and transaction-related infrastructure.
Question 7
Do I still need a database driver when using the JPA starter?
Answer:
Yes. I still need to add a database driver such as PostgreSQL, MySQL, or MariaDB.
Question 8
What starter is commonly used for Bean Validation?
Answer:
Use:
spring-boot-starter-validation
Question 9
What can happen when I add the security starter?
Answer:
Adding the security starter can trigger security auto-configuration. In a web app, endpoints may become secured by default until I configure security behavior.
Question 10
What is spring-boot-starter-actuator used for?
Answer:
spring-boot-starter-actuator is used for production-ready monitoring and management endpoints such as health, info, metrics, beans, and conditions.
Question 11
What is dependency management?
Answer:
Dependency management means using a known set of dependency versions so libraries work correctly together.
Question 12
Why does Spring Boot manage dependency versions?
Answer:
Spring Boot manages dependency versions to reduce conflicts and ensure that common libraries are compatible with the selected Spring Boot version.
Question 13
Should I usually specify versions manually for Boot-managed dependencies?
Answer:
No. I should usually omit versions for dependencies managed by Spring Boot and let Boot choose compatible versions.
Question 14
What is the Spring Boot parent POM?
Answer:
The Spring Boot parent POM is spring-boot-starter-parent. It provides dependency management, plugin management, and sensible Maven defaults.
Question 15
What is the Spring Boot BOM?
Answer:
The Spring Boot BOM is spring-boot-dependencies. It is a Bill of Materials that defines dependency versions for common libraries.
Question 16
What is the difference between the parent POM and the BOM?
Answer:
The parent POM provides dependency management and plugin management as a Maven parent. The BOM provides dependency version management without being used as a parent.
Question 17
What is runtimeOnly useful for?
Answer:
runtimeOnly is useful for dependencies needed only at runtime, such as a database driver.
Question 18
What is testImplementation useful for?
Answer:
testImplementation is useful for dependencies needed only in tests, such as spring-boot-starter-test.
Question 19
Why is mixing different Spring Boot starter versions dangerous?
Answer:
Mixing different Spring Boot starter versions can create incompatible dependency versions and cause runtime errors or bean creation problems.
Question 20
How can I inspect dependency trees?
Answer:
Use:
./gradlew dependencies
or:
./gradlew dependencyInsight --dependency dependency-name
For Maven:
mvn dependency:tree
Final Memory Sentences
- A Spring Boot starter is a dependency bundle.
- Starters reduce dependency boilerplate.
- Starters bring libraries; auto-configuration configures them.
- A transitive dependency is brought indirectly by another dependency.
spring-boot-starter-webis for Spring MVC web apps.spring-boot-starter-webfluxis for reactive web apps.spring-boot-starter-data-jpagives JPA and Hibernate support.- JPA starter does not replace the database driver.
- Use
spring-boot-starter-validationfor Bean Validation. - Security starter can secure endpoints by default.
- Actuator starter adds production monitoring endpoints.
- Spring Boot dependency management provides compatible versions.
- Usually omit versions for Boot-managed dependencies.
- The parent POM provides Maven dependency and plugin management.
- The BOM provides dependency version management without using the Boot parent.
- Avoid manually overriding versions unless necessary.
- Use dependency tree tools to inspect dependency problems.