upgrade to Spring Boot 4.2.1
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
|
||||
**Status:**
|
||||
- proposed: 2026-06-09
|
||||
- accepted: -
|
||||
- accepted: 2026-06-09
|
||||
- rejected: -
|
||||
- superseded: -
|
||||
|
||||
**Decision [proposed]:** Spring Boot 4.0 — only actively-supported version; springmockk workaround via @TestConfiguration until a compatible release is published.
|
||||
**Decision [accepted]:** Spring Boot 4.0.6 — only actively-supported version; springmockk 5.0.1 provides @MockkBean for Spring Boot 4.0.
|
||||
|
||||
## Context and Problem Statement
|
||||
|
||||
@@ -34,12 +34,12 @@ Spring Boot 4.0 moves to Spring Framework 7 and Jakarta EE 11.
|
||||
|
||||
The key ecosystem dependencies and their Spring Boot 4.0 compatibility status:
|
||||
|
||||
| Dependency | Role | Spring Boot 4.0 status |
|
||||
|---|---|---|
|
||||
| [picocli-spring-boot-starter](https://picocli.info/) | CLI wiring | Untested; last documented target is Spring Boot 3.1. The integration is minimal (one `IFactory` bean), so it likely works in practice. |
|
||||
| [springmockk](https://github.com/Ninja-Squad/springmockk) | `@MockkBean` in tests | **Incompatible** — confirmed Spring Boot 3.x only. |
|
||||
| [kotest-extensions-spring](https://github.com/kotest/kotest-extensions-spring) | Kotest + `@SpringBootTest` | Compatibility unconfirmed. |
|
||||
| [wiremock-spring-boot](https://wiremock.org/docs/spring-boot/) | HTTP stubbing in tests | **Compatible** — Spring Boot 4.0 explicitly supported since January 2026. |
|
||||
| Dependency | Version | Role | Spring Boot 4.0 status |
|
||||
|---|---|---|---|
|
||||
| [picocli-spring-boot-starter](https://picocli.info/) | 4.7.6 | CLI wiring | **Compatible** — `ApplicationContextTest` confirms context wiring works. |
|
||||
| [springmockk](https://github.com/Ninja-Squad/springmockk) | 5.0.1 | `@MockkBean` in tests | **Compatible** — 5.x released specifically for Spring Boot 4.0; `@MockkBean` verified. |
|
||||
| [kotest-extensions-spring](https://github.com/kotest/kotest-extensions-spring) | 6.1.5 | Kotest + `@SpringBootTest` | **Compatible** — 6.x (new groupId `io.kotest`) required; config moved to `io.kotest.provided.ProjectConfig`. |
|
||||
| [wiremock-spring-boot](https://wiremock.org/docs/spring-boot/) | 4.2.1 | HTTP stubbing in tests | **Compatible** — Spring Boot 4.0 explicitly supported since January 2026. |
|
||||
|
||||
## Considered Options
|
||||
|
||||
@@ -76,12 +76,9 @@ The current and only actively-supported major release.
|
||||
|
||||
#### Disadvantages
|
||||
|
||||
- **springmockk is incompatible.** The `@MockkBean` / `@SpykBean` annotations are not available.
|
||||
This matters in particular for `@WebMvcTest` (controller error-behaviour) and
|
||||
`@DataJpaTest`-adjacent tests where collaborators need to be mocked in the Spring context.
|
||||
The workaround is to register MockK mocks as Spring beans via `@TestConfiguration`,
|
||||
which preserves full MockK syntax (`every { }`, `verify { }`) at the cost of one
|
||||
inner configuration class per test file and an explicit `clearMocks()` call in `beforeEach`:
|
||||
- **springmockk 5.x is required.** Version 4.x is Spring Boot 3.x only. Version 5.0.1 adds
|
||||
Spring Boot 4.0 support; `@MockkBean` / `@SpykBean` work as expected.
|
||||
As an alternative, register MockK mocks via `@TestConfiguration` without the springmockk dependency:
|
||||
```kotlin
|
||||
@WebMvcTest(SomeController::class)
|
||||
@Import(SomeControllerTest.Mocks::class)
|
||||
@@ -93,17 +90,12 @@ The current and only actively-supported major release.
|
||||
@Autowired lateinit var someService: SomeService
|
||||
init {
|
||||
beforeEach { clearMocks(someService) }
|
||||
// full MockK syntax available
|
||||
}
|
||||
}
|
||||
```
|
||||
This is more verbose than `@MockkBean` but avoids mixing Mockito and MockK.
|
||||
Revisit once springmockk publishes a Spring Boot 4.0-compatible release.
|
||||
- **picocli-spring-boot-starter is untested against Spring Boot 4.0.**
|
||||
The risk is low (the auto-configuration is a single `IFactory` bean with no framework-version-specific API),
|
||||
but it cannot be assumed safe until verified by a running context test.
|
||||
- **kotest-extensions-spring** compatibility needs verification before the first
|
||||
`@SpringBootTest` test is written.
|
||||
- **picocli-spring-boot-starter** context wiring confirmed via `ApplicationContextTest`.
|
||||
- **kotest-extensions-spring 6.x** (groupId `io.kotest`) is required for Spring Boot 4.0.
|
||||
The project config must be placed at `io.kotest.provided.ProjectConfig` (Kotest 6 discovery requirement).
|
||||
- Relatively new GA; fewer community examples for the 4.0 generation.
|
||||
|
||||
## Decision Outcome
|
||||
@@ -124,9 +116,4 @@ The main reasons:
|
||||
- kotest-extensions-spring compatibility must be verified before the
|
||||
first `@SpringBootTest` test is written.
|
||||
|
||||
Open items before the code is upgraded:
|
||||
1. Bump Spring Boot to 4.0.6 and verify `ApplicationContextTest` still passes.
|
||||
2. Confirm picocli-spring-boot-starter works under the new context.
|
||||
3. Confirm kotest-extensions-spring works with Spring Boot 4.0.
|
||||
4. Replace `@MockkBean` usages with the `@TestConfiguration` + `mockk()` pattern
|
||||
until springmockk publishes a compatible release.
|
||||
All ecosystem blockers are resolved. The codebase runs Spring Boot 4.0.6.
|
||||
|
||||
Reference in New Issue
Block a user