From 6f3773ad820082d7ae9b1410f2afc691a01e7b1f Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Sun, 22 Feb 2026 12:42:26 +0000 Subject: [PATCH 1/7] feat : Upgrade to spring boot 4 --- poc-rest-api/spring-boot-rest-webmvc/pom.xml | 182 +++++++++--------- .../SpringBootRestWebMvcApplication.java | 2 +- .../poc/webmvc/batch/CustomItemProcessor.java | 2 +- .../poc/webmvc/batch/CustomItemReader.java | 6 +- .../poc/webmvc/batch/CustomItemWriter.java | 4 +- .../webmvc/batch/JobInvokerController.java | 12 +- .../poc/webmvc/batch/ReportsExecutionJob.java | 4 + .../poc/webmvc/config/WebMvcConfig.java | 2 +- .../poc/webmvc/exception/ApiError.java | 2 +- .../exception/LowerCaseClassNameResolver.java | 2 +- .../batch/SpringBatchIntegrationTest.java | 5 + .../common/AbstractIntegrationTest.java | 8 +- .../AbstractPostgreSQLContainerBase.java | 6 +- .../webmvc/controller/PostControllerTest.java | 2 +- .../webmvc/repository/PostRepositoryTest.java | 4 +- 15 files changed, 122 insertions(+), 121 deletions(-) diff --git a/poc-rest-api/spring-boot-rest-webmvc/pom.xml b/poc-rest-api/spring-boot-rest-webmvc/pom.xml index 9e5bb1d17..ee8b1126c 100644 --- a/poc-rest-api/spring-boot-rest-webmvc/pom.xml +++ b/poc-rest-api/spring-boot-rest-webmvc/pom.xml @@ -7,7 +7,7 @@ org.springframework.boot spring-boot-starter-parent - 3.5.11 + 4.0.3 @@ -18,7 +18,9 @@ 21 1.6.3 - 2.8.15 + 3.0.1 + + 1.0.0 3.13.0 12.2.0 @@ -43,7 +45,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc org.springframework.boot @@ -66,8 +68,8 @@ caffeine - org.liquibase - liquibase-core + org.springframework.boot + spring-boot-starter-liquibase org.mapstruct @@ -100,9 +102,14 @@ lombok true + + org.projectlombok + lombok-mapstruct-binding + 0.2.0 + org.springframework.boot - spring-boot-starter-test + spring-boot-starter-webmvc-test test @@ -110,14 +117,29 @@ spring-batch-test test + + org.springframework.boot + spring-boot-resttestclient + test + + + org.springframework.boot + spring-boot-starter-data-jpa-test + test + + + org.springframework.boot + spring-boot-starter-restclient + test + org.testcontainers - junit-jupiter + testcontainers-junit-jupiter test org.testcontainers - postgresql + testcontainers-postgresql test @@ -215,113 +237,81 @@ false - - - org.codehaus.gmaven - groovy-maven-plugin - 2.1.1 - - - generate-sources - - execute - - - - db = new org.testcontainers.containers.PostgreSQLContainer("postgres:latest") - .withUsername("${db.username}") - .withDatabaseName("rest") - .withPassword("${db.password}"); - db.start(); - project.properties.setProperty('db.url', db.getJdbcUrl()); - - - - + + org.apache.maven.plugins + maven-surefire-plugin + + + dev.sivalabs + testcontainers-jooq-codegen-maven-plugin + ${testcontainers-jooq-codegen-maven-plugin.version} org.testcontainers - postgresql + testcontainers-postgresql ${testcontainers.version} - - - - - org.flywaydb - flyway-maven-plugin - ${flyway.version} - - - generate-sources - - migrate - - - ${db.url} - ${db.username} - ${db.password} - - filesystem:src/main/resources/db/migration - - - - - - org.flywaydb - flyway-database-postgresql - ${flyway.version} + org.postgresql + postgresql + ${postgresql.version} + + + org.jooq + jooq-codegen + ${jooq.version} - - - - org.jooq - jooq-codegen-maven - - java-generator - generate-sources + generate-jooq-sources generate - + generate-sources - - ${db.url} - ${db.username} - ${db.password} - - - - public - - - com.example.poc.webmvc.testcontainersflyway.db - target/generated-sources/jooq - - + + + POSTGRES + + postgres:18.2-alpine + + + db.changelog-master.yaml + src/main/resources/db/changelog + public + + + + + + .* + DATABASECHANGELOG.* + public + + + com.example.poc.webmvc.testcontainersflyway.db + target/generated-sources/jooq + + + - - - org.apache.maven.plugins - maven-surefire-plugin - - - ${db.url} - ${db.username} - ${db.password} - - - com.diffplug.spotless spotless-maven-plugin @@ -329,7 +319,7 @@ - 1.25.2 + 1.28.0 diff --git a/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/SpringBootRestWebMvcApplication.java b/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/SpringBootRestWebMvcApplication.java index 6f2689075..78ed3c9db 100644 --- a/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/SpringBootRestWebMvcApplication.java +++ b/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/SpringBootRestWebMvcApplication.java @@ -4,8 +4,8 @@ import com.example.poc.webmvc.config.ApplicationProperties; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.persistence.autoconfigure.EntityScan; @SpringBootApplication @EntityScan(basePackages = {"com.example.poc.webmvc.entities"}) diff --git a/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/batch/CustomItemProcessor.java b/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/batch/CustomItemProcessor.java index 53662a328..1ab2d2a4b 100644 --- a/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/batch/CustomItemProcessor.java +++ b/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/batch/CustomItemProcessor.java @@ -11,7 +11,7 @@ import java.util.stream.Collector; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; -import org.springframework.batch.item.ItemProcessor; +import org.springframework.batch.infrastructure.item.ItemProcessor; import org.springframework.stereotype.Component; @RequiredArgsConstructor diff --git a/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/batch/CustomItemReader.java b/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/batch/CustomItemReader.java index 69d2b832c..19a795252 100644 --- a/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/batch/CustomItemReader.java +++ b/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/batch/CustomItemReader.java @@ -8,10 +8,10 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.annotation.BeforeStep; -import org.springframework.batch.item.database.AbstractPagingItemReader; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.step.StepExecution; +import org.springframework.batch.infrastructure.item.database.AbstractPagingItemReader; import org.springframework.stereotype.Component; @RequiredArgsConstructor diff --git a/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/batch/CustomItemWriter.java b/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/batch/CustomItemWriter.java index 455458bd7..6c210125b 100644 --- a/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/batch/CustomItemWriter.java +++ b/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/batch/CustomItemWriter.java @@ -4,8 +4,8 @@ import com.example.poc.webmvc.dto.PostDTO; import java.util.List; import lombok.extern.slf4j.Slf4j; -import org.springframework.batch.item.Chunk; -import org.springframework.batch.item.ItemWriter; +import org.springframework.batch.infrastructure.item.Chunk; +import org.springframework.batch.infrastructure.item.ItemWriter; import org.springframework.stereotype.Component; @Component diff --git a/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/batch/JobInvokerController.java b/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/batch/JobInvokerController.java index a6517973d..ee763afc0 100644 --- a/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/batch/JobInvokerController.java +++ b/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/batch/JobInvokerController.java @@ -3,11 +3,11 @@ import java.util.Date; import lombok.RequiredArgsConstructor; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; -import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; +import org.springframework.batch.core.launch.JobOperator; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @@ -15,7 +15,7 @@ @RequiredArgsConstructor public class JobInvokerController { - private final JobLauncher jobLauncher; + private final JobOperator jobLauncher; private final Job executionJob; diff --git a/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/batch/ReportsExecutionJob.java b/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/batch/ReportsExecutionJob.java index e591e26bf..0270c7e8e 100644 --- a/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/batch/ReportsExecutionJob.java +++ b/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/batch/ReportsExecutionJob.java @@ -7,9 +7,13 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.batch.core.*; import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.support.RunIdIncrementer; +import org.springframework.batch.core.listener.JobExecutionListener; import org.springframework.batch.core.repository.JobRepository; +import org.springframework.batch.core.step.Step; import org.springframework.batch.core.step.builder.StepBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/config/WebMvcConfig.java b/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/config/WebMvcConfig.java index c6077b972..cdc0947d0 100644 --- a/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/config/WebMvcConfig.java +++ b/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/config/WebMvcConfig.java @@ -1,8 +1,8 @@ /* Licensed under Apache-2.0 2025 */ package com.example.poc.webmvc.config; +import org.jspecify.annotations.NonNull; import org.springframework.context.annotation.Configuration; -import org.springframework.lang.NonNull; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; diff --git a/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/exception/ApiError.java b/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/exception/ApiError.java index 76e688135..8b972a315 100644 --- a/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/exception/ApiError.java +++ b/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/exception/ApiError.java @@ -3,7 +3,6 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver; import jakarta.validation.ConstraintViolation; import java.time.LocalDateTime; import java.util.ArrayList; @@ -17,6 +16,7 @@ import org.springframework.http.HttpStatusCode; import org.springframework.validation.FieldError; import org.springframework.validation.ObjectError; +import tools.jackson.databind.annotation.JsonTypeIdResolver; @Data @JsonTypeInfo( diff --git a/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/exception/LowerCaseClassNameResolver.java b/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/exception/LowerCaseClassNameResolver.java index 7e45b3c3a..c0a349dc3 100644 --- a/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/exception/LowerCaseClassNameResolver.java +++ b/poc-rest-api/spring-boot-rest-webmvc/src/main/java/com/example/poc/webmvc/exception/LowerCaseClassNameResolver.java @@ -2,8 +2,8 @@ package com.example.poc.webmvc.exception; import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.databind.jsontype.impl.TypeIdResolverBase; import java.util.Locale; +import tools.jackson.databind.jsontype.impl.TypeIdResolverBase; class LowerCaseClassNameResolver extends TypeIdResolverBase { diff --git a/poc-rest-api/spring-boot-rest-webmvc/src/test/java/com/example/poc/webmvc/batch/SpringBatchIntegrationTest.java b/poc-rest-api/spring-boot-rest-webmvc/src/test/java/com/example/poc/webmvc/batch/SpringBatchIntegrationTest.java index d84a540f3..edf81f665 100644 --- a/poc-rest-api/spring-boot-rest-webmvc/src/test/java/com/example/poc/webmvc/batch/SpringBatchIntegrationTest.java +++ b/poc-rest-api/spring-boot-rest-webmvc/src/test/java/com/example/poc/webmvc/batch/SpringBatchIntegrationTest.java @@ -7,6 +7,11 @@ import java.util.Date; import org.junit.jupiter.api.*; import org.springframework.batch.core.*; +import org.springframework.batch.core.job.Job; +import org.springframework.batch.core.job.JobExecution; +import org.springframework.batch.core.job.JobInstance; +import org.springframework.batch.core.job.parameters.JobParameters; +import org.springframework.batch.core.job.parameters.JobParametersBuilder; import org.springframework.batch.test.JobLauncherTestUtils; import org.springframework.batch.test.JobRepositoryTestUtils; import org.springframework.batch.test.context.SpringBatchTest; diff --git a/poc-rest-api/spring-boot-rest-webmvc/src/test/java/com/example/poc/webmvc/common/AbstractIntegrationTest.java b/poc-rest-api/spring-boot-rest-webmvc/src/test/java/com/example/poc/webmvc/common/AbstractIntegrationTest.java index 620782d0b..e7c4ee101 100644 --- a/poc-rest-api/spring-boot-rest-webmvc/src/test/java/com/example/poc/webmvc/common/AbstractIntegrationTest.java +++ b/poc-rest-api/spring-boot-rest-webmvc/src/test/java/com/example/poc/webmvc/common/AbstractIntegrationTest.java @@ -6,16 +6,18 @@ import java.time.Duration; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.restclient.RestTemplateBuilder; +import org.springframework.boot.resttestclient.LocalHostUriTemplateHandler; +import org.springframework.boot.resttestclient.TestRestTemplate; +import org.springframework.boot.resttestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.boot.test.web.client.LocalHostUriTemplateHandler; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.context.annotation.Bean; import org.springframework.core.env.Environment; import org.springframework.test.context.ActiveProfiles; @ActiveProfiles({PROFILE_TEST, PROFILE_IT}) +@AutoConfigureTestRestTemplate @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public abstract class AbstractIntegrationTest extends AbstractPostgreSQLContainerBase { diff --git a/poc-rest-api/spring-boot-rest-webmvc/src/test/java/com/example/poc/webmvc/common/AbstractPostgreSQLContainerBase.java b/poc-rest-api/spring-boot-rest-webmvc/src/test/java/com/example/poc/webmvc/common/AbstractPostgreSQLContainerBase.java index 5ef6d3310..b43401b7a 100644 --- a/poc-rest-api/spring-boot-rest-webmvc/src/test/java/com/example/poc/webmvc/common/AbstractPostgreSQLContainerBase.java +++ b/poc-rest-api/spring-boot-rest-webmvc/src/test/java/com/example/poc/webmvc/common/AbstractPostgreSQLContainerBase.java @@ -3,14 +3,14 @@ import org.springframework.test.context.DynamicPropertyRegistry; import org.springframework.test.context.DynamicPropertySource; -import org.testcontainers.containers.PostgreSQLContainer; import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.postgresql.PostgreSQLContainer; public abstract class AbstractPostgreSQLContainerBase { @Container - protected static final PostgreSQLContainer sqlContainer = - new PostgreSQLContainer<>("postgres:18-alpine"); + protected static final PostgreSQLContainer sqlContainer = + new PostgreSQLContainer("postgres:18-alpine"); static { sqlContainer.start(); diff --git a/poc-rest-api/spring-boot-rest-webmvc/src/test/java/com/example/poc/webmvc/controller/PostControllerTest.java b/poc-rest-api/spring-boot-rest-webmvc/src/test/java/com/example/poc/webmvc/controller/PostControllerTest.java index 4c2aa51fd..3d8426b05 100644 --- a/poc-rest-api/spring-boot-rest-webmvc/src/test/java/com/example/poc/webmvc/controller/PostControllerTest.java +++ b/poc-rest-api/spring-boot-rest-webmvc/src/test/java/com/example/poc/webmvc/controller/PostControllerTest.java @@ -16,7 +16,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.hateoas.MediaTypes; import org.springframework.http.HttpHeaders; import org.springframework.test.context.bean.override.mockito.MockitoBean; diff --git a/poc-rest-api/spring-boot-rest-webmvc/src/test/java/com/example/poc/webmvc/repository/PostRepositoryTest.java b/poc-rest-api/spring-boot-rest-webmvc/src/test/java/com/example/poc/webmvc/repository/PostRepositoryTest.java index 669b1cc43..b249387b2 100644 --- a/poc-rest-api/spring-boot-rest-webmvc/src/test/java/com/example/poc/webmvc/repository/PostRepositoryTest.java +++ b/poc-rest-api/spring-boot-rest-webmvc/src/test/java/com/example/poc/webmvc/repository/PostRepositoryTest.java @@ -22,8 +22,8 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest; +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase; @DataJpaTest @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) From 333751edb0d3608e2e7ca5de7f5a00ee3f08af56 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Sun, 22 Feb 2026 14:36:02 +0000 Subject: [PATCH 2/7] fix compilation issues --- poc-rest-api/spring-boot-rest-webmvc/pom.xml | 38 ++++--------------- .../poc/webmvc/batch/CustomItemReader.java | 6 ++- .../webmvc/batch/JobInvokerController.java | 6 +-- .../poc/webmvc/batch/ReportsExecutionJob.java | 11 ++---- .../exception/LowerCaseClassNameResolver.java | 11 +++--- .../batch/SpringBatchIntegrationTest.java | 20 ++++++---- .../common/AbstractIntegrationTest.java | 17 ++------- .../controller/PingControllerITTest.java | 37 ++++++++---------- .../controller/PostControllerITTest.java | 4 +- 9 files changed, 58 insertions(+), 92 deletions(-) diff --git a/poc-rest-api/spring-boot-rest-webmvc/pom.xml b/poc-rest-api/spring-boot-rest-webmvc/pom.xml index ee8b1126c..9629d99ba 100644 --- a/poc-rest-api/spring-boot-rest-webmvc/pom.xml +++ b/poc-rest-api/spring-boot-rest-webmvc/pom.xml @@ -25,9 +25,6 @@ 3.13.0 12.2.0 3.2.1 - - local - local @@ -113,8 +110,8 @@ test - org.springframework.batch - spring-batch-test + org.springframework.boot + spring-boot-starter-batch-test test @@ -286,11 +283,11 @@ --> postgres:18.2-alpine - - db.changelog-master.yaml - src/main/resources/db/changelog - public - + + + filesystem:src/main/resources/db/migration + +