Skip to content

Add missing WebClient Spring Boot Starter (Spring Boot 4) #872

@ghusta

Description

@ghusta

What problem are you trying to solve?

Add Spring Boot starter spring-boot-starter-webclient, provided in a separate starter as of Spring Boot 4.
See details here:

With Spring Boot 4.0, applications can now use the “org.springframework.boot:spring-boot-starter-webclient” or “org.springframework.boot:spring-boot-starter-restclient” to express the need for an HTTP client.

Steps

  • add dependency spring-boot-starter-webclient if org.springframework.web.reactive.function.client.WebClient is used in project
  • add dependency spring-boot-starter-webclient-test if org.springframework.web.reactive.function.client.WebClient is used in project
  • remove dependency reactor-test (dependency of spring-boot-starter-webclient-test)
  • rename some classes from org.springframework.boot.web.reactive.function.client to org.springframework.boot.webclient

Quick start

A first recipe that I tested. Second part is in its own recipe to ease testing.
Maybe some classes are missing from the package renaming.

---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.spring.boot4.AddWebClientStarter
displayName: Add missing WebClient Spring Boot Starter
description: >-
  Add Spring Boot starter `spring-boot-starter-webclient`, provided in a separate starter as of Spring Boot 4.
  See details about [new Spring Boot Starters](https://spring.io/blog/2025/09/30/the-state-of-http-clients-in-spring#new-spring-boot-starters).
tags:
  - spring
  - boot
recipeList:
  - org.openrewrite.java.dependencies.AddDependency:
      groupId: org.springframework.boot
      artifactId: spring-boot-starter-webclient
      scope: compile
      acceptTransitive: false
      onlyIfUsing: "org.springframework.web.reactive.function.client.WebClient"
  - org.openrewrite.java.dependencies.AddDependency:
      groupId: org.springframework.boot
      artifactId: spring-boot-starter-webclient-test
      scope: test
      acceptTransitive: false
      onlyIfUsing: "org.springframework.web.reactive.function.client.WebClient"
  # remove reactor-test, dependency of spring-boot-starter-webclient-test
  - org.openrewrite.java.dependencies.RemoveDependency:
      groupId: io.projectreactor
      artifactId: reactor-test
      scope: test
      configuration: testImplementation
  - org.openrewrite.java.spring.boot4.WebClientPackageRenaming
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.spring.boot4.WebClientPackageRenaming
displayName: Package name change in `spring-boot-webclient`
description: >-
  Package name change in `spring-boot-webclient`.
tags:
  - spring
  - boot
recipeList:
  - org.openrewrite.java.ChangePackage:
      oldPackageName: org.springframework.boot.web.reactive.function.client
      newPackageName: org.springframework.boot.webclient
      recursive: true
  - org.openrewrite.java.ChangePackage:
      oldPackageName: org.springframework.boot.autoconfigure.web.reactive.function.client
      newPackageName: org.springframework.boot.webclient.autoconfigure
      recursive: true

Any additional context

References:

Related:

Are you interested in [contributing this recipe to OpenRewrite]

OK

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions