Skip to content

Commit cd2d071

Browse files
Copilotrashidi
andauthored
Fix three failing test modules for Spring Boot 4.0 upgrade
batch-rest-repository: Add spring-boot-starter-jdbc (with HikariCP) to fix "No supported DataSource type found" from DataSourceBuilder.create(). Also disable Jackson 3.x FAIL_ON_TRAILING_TOKENS for JacksonJsonObjectReader. batch-skip-step: Disable Jackson 3.x FAIL_ON_TRAILING_TOKENS which is now enabled by default and breaks Spring Batch's JacksonJsonObjectReader. cloud-jdbc-env-repo: Add DataSource and JdbcTemplate auto-configuration to bootstrap context via spring.factories so the JDBC environment repository can be created during Config Server bootstrap. Agent-Logs-Url: https://github.com/rashidi/spring-boot-tutorials/sessions/45a35581-8e7d-4608-9f4d-38ea0fa68d3b Co-authored-by: rashidi <380073+rashidi@users.noreply.github.com>
1 parent 68901f0 commit cd2d071

4 files changed

Lines changed: 12 additions & 3 deletions

File tree

batch-rest-repository/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ dependencies {
2323
implementation("tools.jackson.core:jackson-databind")
2424
runtimeOnly("com.mysql:mysql-connector-j")
2525
testImplementation("org.springframework.boot:spring-boot-starter-test")
26-
testImplementation("org.springframework.boot:spring-boot-jdbc")
26+
testImplementation("org.springframework.boot:spring-boot-starter-jdbc")
2727
testImplementation("org.springframework.boot:spring-boot-testcontainers")
2828
testImplementation("org.springframework.batch:spring-batch-test")
2929
testImplementation("org.testcontainers:testcontainers-junit-jupiter")

batch-rest-repository/src/main/java/zin/rashidi/boot/batch/rest/user/UserJobConfiguration.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package zin.rashidi.boot.batch.rest.user;
22

33
import java.net.MalformedURLException;
4+
import tools.jackson.databind.DeserializationFeature;
45
import tools.jackson.databind.json.JsonMapper;
56
import org.springframework.batch.core.job.Job;
67
import org.springframework.batch.core.job.builder.JobBuilder;
@@ -24,7 +25,9 @@
2425
@Configuration
2526
class UserJobConfiguration {
2627

27-
private static final JsonMapper OBJECT_MAPPER = new JsonMapper();
28+
private static final JsonMapper OBJECT_MAPPER = JsonMapper.builder()
29+
.disable(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)
30+
.build();
2831

2932
private final JobRepository jobRepository;
3033
private final PlatformTransactionManager transactionManager;

batch-skip-step/src/main/java/zin/rashidi/boot/batch/user/UserJobConfiguration.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package zin.rashidi.boot.batch.user;
22

3+
import tools.jackson.databind.DeserializationFeature;
34
import tools.jackson.databind.json.JsonMapper;
45
import org.springframework.batch.core.job.Job;
56
import org.springframework.batch.core.job.builder.JobBuilder;
@@ -25,7 +26,9 @@
2526
@Configuration
2627
class UserJobConfiguration {
2728

28-
private static final JsonMapper OBJECT_MAPPER = new JsonMapper();
29+
private static final JsonMapper OBJECT_MAPPER = JsonMapper.builder()
30+
.disable(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)
31+
.build();
2932

3033
private JsonItemReader<UserFile> reader() {
3134
JacksonJsonObjectReader<UserFile> reader = new JacksonJsonObjectReader<>(UserFile.class);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
org.springframework.cloud.bootstrap.BootstrapConfiguration=\
2+
org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration,\
3+
org.springframework.boot.jdbc.autoconfigure.JdbcTemplateAutoConfiguration

0 commit comments

Comments
 (0)