File tree Expand file tree Collapse file tree 4 files changed +82
-0
lines changed
spring-cloud-task-samples/batch-job Expand file tree Collapse file tree 4 files changed +82
-0
lines changed Original file line number Diff line number Diff line change @@ -38,3 +38,9 @@ mvn -Pnative native:compile
3838----
3939./target/batch-job
4040----
41+
42+ == Run the application with a Postgesql test container
43+ [source,shell]
44+ ----
45+ ./mvnw spring-boot:test-run
46+ ----
Original file line number Diff line number Diff line change 5757 <groupId >org.mariadb.jdbc</groupId >
5858 <artifactId >mariadb-java-client</artifactId >
5959 </dependency >
60+ <dependency >
61+ <groupId >org.testcontainers</groupId >
62+ <artifactId >postgresql</artifactId >
63+ <scope >test</scope >
64+ </dependency >
65+ <dependency >
66+ <groupId >org.springframework.boot</groupId >
67+ <artifactId >spring-boot-testcontainers</artifactId >
68+ <scope >test</scope >
69+ </dependency >
70+ <dependency >
71+ <groupId >org.postgresql</groupId >
72+ <artifactId >postgresql</artifactId >
73+ </dependency >
6074 </dependencies >
6175
6276 <repositories >
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2023 the original author or authors.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * https://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ package io .spring ;
18+
19+ import org .springframework .boot .test .context .TestConfiguration ;
20+ import org .springframework .boot .testcontainers .service .connection .ServiceConnection ;
21+ import org .springframework .context .annotation .Bean ;
22+ import org .testcontainers .containers .PostgreSQLContainer ;
23+ import org .testcontainers .utility .DockerImageName ;
24+
25+ @ TestConfiguration (proxyBeanMethods = false )
26+ class BatchJobTestConfiguration {
27+
28+ @ Bean
29+ @ ServiceConnection
30+ public PostgreSQLContainer <?> postgresSQLContainer () {
31+ return new PostgreSQLContainer (DockerImageName .parse ("postgres:15.1" ));
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2023 the original author or authors.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * https://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ package io .spring ;
18+
19+ import org .springframework .boot .SpringApplication ;
20+
21+ public class TestBatchJobApp {
22+
23+ public static void main (String [] args ) {
24+ String [] myArgs = {"--spring.batch.jdbc.initialize-schema=always" };
25+ SpringApplication .from (BatchJobApplication ::main ).
26+ with (BatchJobTestConfiguration .class ).
27+ run (myArgs );
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments