Skip to content

Propose Spring Boot 3.4.x Upgrade and @MockBean to @MockitoBean Migration #47

@eggzuxi

Description

@eggzuxi

Current Situation
The spring-guides/gs-testing-web repository currently uses Spring Boot version 3.3.0 in its build.gradle. In this version, the @MockBean annotation (org.springframework.boot.test.mock.mockito.MockBean) used in the test examples works without any issues.

Problem and Motivation
However, I recently observed in a personal project using Spring Boot 3.4.4 that the @MockBean annotation is now deprecated since version 3.4.0 and marked for removal. This deprecation is officially documented in the Spring Boot API reference:
👉 Spring Boot @MockBean API Documentation

This means that users following this guide or attempting to upgrade the project to Spring Boot 3.4.x or later will encounter this deprecation warning, which can be confusing or lead to future breaking changes.

Proposed Solution
Therefore, I propose upgrading the project's Spring Boot version to the latest stable release in the 3.4.x line (e.g., 3.4.5). Following this upgrade, I will propose migrating the @MockBean usages in test files—such as src/test/java/com/example/testingweb/WebMockTest.java—to the recommended @MockitoBean (org.springframework.test.context.bean.override.mockito.MockitoBean).

Expected Benefits

  • Modernizes the codebase to align with the latest Spring Boot recommendations.
  • Ensures the guide remains relevant and useful for users on newer Spring Boot versions, preventing them from encountering deprecation warnings.
  • Leverages the latest features and security patches available in Spring Boot 3.4.x.
  • Addresses a potential breaking change in future Spring Boot releases, improving long-term maintainability.

Discussion Request
I'd appreciate the maintainers' thoughts on this proposed upgrade and migration. Are there any specific considerations or preferences regarding a 3.4.x version?

If this proposal is acceptable, I’d be happy to open a pull request to implement the upgrade and the annotation migration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions