diff --git a/spring-cloud-task-samples/batch-job/README.adoc b/spring-cloud-task-samples/batch-job/README.adoc
index 035285f4..0c44ccab 100644
--- a/spring-cloud-task-samples/batch-job/README.adoc
+++ b/spring-cloud-task-samples/batch-job/README.adoc
@@ -38,3 +38,9 @@ mvn -Pnative native:compile
----
./target/batch-job
----
+
+== Run the application with a Postgesql test container
+[source,shell]
+----
+./mvnw spring-boot:test-run
+----
diff --git a/spring-cloud-task-samples/batch-job/pom.xml b/spring-cloud-task-samples/batch-job/pom.xml
index ecabf008..d3019d15 100644
--- a/spring-cloud-task-samples/batch-job/pom.xml
+++ b/spring-cloud-task-samples/batch-job/pom.xml
@@ -57,6 +57,20 @@
org.mariadb.jdbc
mariadb-java-client
+
+ org.testcontainers
+ postgresql
+ test
+
+
+ org.springframework.boot
+ spring-boot-testcontainers
+ test
+
+
+ org.postgresql
+ postgresql
+
diff --git a/spring-cloud-task-samples/batch-job/src/test/java/io/spring/BatchJobTestConfiguration.java b/spring-cloud-task-samples/batch-job/src/test/java/io/spring/BatchJobTestConfiguration.java
new file mode 100644
index 00000000..1d7d6df0
--- /dev/null
+++ b/spring-cloud-task-samples/batch-job/src/test/java/io/spring/BatchJobTestConfiguration.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2023 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.spring;
+
+import org.springframework.boot.test.context.TestConfiguration;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
+import org.springframework.context.annotation.Bean;
+import org.testcontainers.containers.PostgreSQLContainer;
+import org.testcontainers.utility.DockerImageName;
+
+@TestConfiguration(proxyBeanMethods = false)
+class BatchJobTestConfiguration {
+
+ @Bean
+ @ServiceConnection
+ public PostgreSQLContainer> postgresSQLContainer() {
+ return new PostgreSQLContainer(DockerImageName.parse("postgres:15.1"));
+ }
+}
diff --git a/spring-cloud-task-samples/batch-job/src/test/java/io/spring/TestBatchJobApp.java b/spring-cloud-task-samples/batch-job/src/test/java/io/spring/TestBatchJobApp.java
new file mode 100644
index 00000000..efbbeac9
--- /dev/null
+++ b/spring-cloud-task-samples/batch-job/src/test/java/io/spring/TestBatchJobApp.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2023 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.spring;
+
+import org.springframework.boot.SpringApplication;
+
+public class TestBatchJobApp {
+
+ public static void main(String[] args) {
+ String[] myArgs = {"--spring.batch.jdbc.initialize-schema=always"};
+ SpringApplication.from(BatchJobApplication::main).
+ with(BatchJobTestConfiguration.class).
+ run(myArgs);
+ }
+}