From 08b5c996e0687577189a067b1ef8b57b15681c6b Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Mon, 7 Sep 2026 09:16:57 +0200 Subject: [PATCH] Upgrade to Spring Boot 4.1.1 and Java 17, fix CI workflow Upgrades the sample from Spring Boot 2.7.1 to 4.1.1 and repairs the JUnit workflow, which had been failing on master. - pom: parent 2.7.1 -> 4.1.1 (Java 17 baseline) - pom: r2dbc-postgresql groupId io.r2dbc -> org.postgresql (moved at 1.x) - pom: drop hardcoded h2 / r2dbc-h2 / r2dbc-postgresql versions so the Spring Boot BOM manages them (h2 now 2.4.240, superseding #4) - pom: drop junit-vintage-engine exclusion, no longer shipped - DemoApplication: ConnectionFactoryInitializer and ResourceDatabasePopulator moved to org.springframework.r2dbc.connection.init - TodoRepositoryTest: DatabaseClient moved to org.springframework.r2dbc.core, and execute() was renamed to sql() - workflow: bump checkout to v7.0.1 and setup-java to v6.0.0 (from #7), add the distribution input that setup-java v2+ requires, and move to Java 17 to match the pom. Without distribution the build fails with "distribution input is required". Verified: 5/5 tests pass, and the packaged jar was run against a real PostgreSQL 16 container (POST / -> 201, GET / -> 200, row persisted). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1427cea2-8234-45b7-8b01-c6ad27a39450 --- .github/workflows/junit-tests.yml | 8 +++++--- pom.xml | 13 ++----------- src/main/java/com/example/demo/DemoApplication.java | 4 ++-- .../java/com/example/demo/TodoRepositoryTest.java | 4 ++-- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/.github/workflows/junit-tests.yml b/.github/workflows/junit-tests.yml index 0150f66..a9346da 100644 --- a/.github/workflows/junit-tests.yml +++ b/.github/workflows/junit-tests.yml @@ -15,10 +15,12 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@0717577d45739eb3c851188b29f50ed6c0b2194e # v2.8.0 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Set up Java - uses: actions/setup-java@0f62d2ad8407a414cddd4790bed06fd9ebda0f56 # v1.4.5 + uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0 with: - java-version: 11 + java-version: 17 + distribution: temurin + cache: maven - name: Build with Maven run: mvn test diff --git a/pom.xml b/pom.xml index d4dfe05..33c136e 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 2.7.1 + 4.1.1 com.example @@ -28,22 +28,19 @@ spring-boot-starter-webflux - io.r2dbc + org.postgresql r2dbc-postgresql - 0.8.12.RELEASE runtime io.r2dbc r2dbc-h2 - 0.9.1.RELEASE test com.h2database h2 - 2.1.214 test @@ -51,12 +48,6 @@ org.springframework.boot spring-boot-starter-test test - - - org.junit.vintage - junit-vintage-engine - - io.projectreactor diff --git a/src/main/java/com/example/demo/DemoApplication.java b/src/main/java/com/example/demo/DemoApplication.java index 6df48fb..4044a58 100644 --- a/src/main/java/com/example/demo/DemoApplication.java +++ b/src/main/java/com/example/demo/DemoApplication.java @@ -4,8 +4,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; import org.springframework.core.io.ClassPathResource; -import org.springframework.data.r2dbc.connectionfactory.init.ConnectionFactoryInitializer; -import org.springframework.data.r2dbc.connectionfactory.init.ResourceDatabasePopulator; +import org.springframework.r2dbc.connection.init.ConnectionFactoryInitializer; +import org.springframework.r2dbc.connection.init.ResourceDatabasePopulator; import io.r2dbc.spi.ConnectionFactory; diff --git a/src/test/java/com/example/demo/TodoRepositoryTest.java b/src/test/java/com/example/demo/TodoRepositoryTest.java index b783587..383888e 100644 --- a/src/test/java/com/example/demo/TodoRepositoryTest.java +++ b/src/test/java/com/example/demo/TodoRepositoryTest.java @@ -4,7 +4,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.data.r2dbc.core.DatabaseClient; +import org.springframework.r2dbc.core.DatabaseClient; import reactor.core.publisher.Hooks; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -24,7 +24,7 @@ public class TodoRepositoryTest { public void setUp() { Hooks.onOperatorDebug(); - database.execute("DELETE FROM todo;").fetch() + database.sql("DELETE FROM todo;").fetch() .rowsUpdated() .as(StepVerifier::create) .expectNextCount(1)