Spring Boot Best Practices

Chapter 1 · Practice 2 of 4

Depend on the specific Spring Boot 4 starters you use

From Versions, starters and dependencies

Why it matters

Spring Boot 4 split auto-configuration into modules per technology, each with its own starter: spring-boot-starter-<tech>, plus a test companion spring-boot-starter-<tech>-test.

What changes for you:

  • spring-boot-starter-web is deprecated in favour of spring-boot-starter-webmvc.
  • Technologies that had no starter before, such as Flyway and Liquibase, now need one explicitly.
  • Test starters bring spring-boot-starter-test along, so you list the technology-specific ones.

Smaller dependency sets mean a smaller classpath, faster startup and fewer surprises from auto-configuration you did not ask for.

Example

Kotlin
dependencies {
    implementation("org.springframework.boot:spring-boot-starter-webmvc")
    implementation("org.springframework.boot:spring-boot-starter-data-jpa")
    implementation("org.springframework.boot:spring-boot-starter-flyway")
    implementation("org.springframework.boot:spring-boot-starter-actuator")
    testImplementation("org.springframework.boot:spring-boot-starter-webmvc-test")
}