Skip to content

Commit 0f07b11

Browse files
fix readme
1 parent 3daa182 commit 0f07b11

File tree

3 files changed

+112
-83
lines changed

3 files changed

+112
-83
lines changed

dbAndCsvBatch/README.md

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,75 +5,75 @@ This module provides practical batch processing samples for:
55
1. Exporting data from a database to a CSV file (DB to CSV).
66
2. Importing data from a CSV file into a database (CSV to DB).
77

8-
## 🐳 Docker Setup
9-
If Docker is not available, download it from the [official Docker website](https://www.docker.com/get-started). Follow the installation instructions for your operating system.
10-
11-
## How to Run
12-
Steps:
13-
1. Build and run the MySQL container:
8+
## 🐳 Database Setup
149
```bash
15-
docker compose down && docker compose build && docker compose up -d
16-
```
10+
# Start MySQL container
11+
docker compose up -d
1712

18-
2. Connect to the MySQL container and verify the setup:
19-
```bash
13+
# Verify database setup
2014
docker exec -it mysql-container mysql -u sampleuser -psamplepassword sampledb
2115

22-
mysql> show databases;
23-
24-
mysql> show tables;
25-
26-
mysql> SELECT * FROM member;
27-
2816
mysql> SELECT * FROM member WHERE delete_flag = 0 AND type IN (1, 2, 3) ORDER BY type ASC;
29-
30-
mysql> exit;
31-
```
32-
## 💻 Step-by-Step Guide:
33-
1. Generate the JAR file
34-
Execute the default task to generate the Spring Boot JAR file:
35-
```bash
36-
cd dbAndCsvBatch
37-
../gradlew
3817
```
39-
40-
2. Verify Generated Files
41-
Confirm that the entity classes and JAR file were successfully created:
4218

19+
## 🔧 How to Run
20+
21+
### 1️⃣ Using Gradle (Recommended)
4322
```bash
44-
# Check generated entity classes
45-
ls -R build/generated-src/jooq
23+
# Run DB to CSV export
24+
./gradlew :dbAndCsvBatch:bootRun --args="--spring.batch.job.name=DB_TO_CSV --spring.profiles.active=local"
4625

47-
# Verify the generated Spring Boot JAR
48-
ls -ls build/libs/dbAndCsvBatch-*.jar
26+
# Run CSV to DB import
27+
./gradlew :dbAndCsvBatch:bootRun --args="--spring.batch.job.name=CSV_TO_DB --spring.profiles.active=local"
4928
```
5029

51-
3. Run Batch Jobs
52-
### For Local Environment
53-
- Export data from DB to CSV:
54-
```bash
55-
java -jar build/libs/dbAndCsvBatch-*.jar --spring.batch.job.name=DB_TO_CSV --spring.profiles.active=local
56-
```
30+
### 2️⃣ Using JAR File
31+
Useful for running with cron jobs or job schedulers. Generate and execute the JAR file as follows:
5732

58-
- Run batch with custom runtime arguments:
33+
### Generate JAR
5934
```bash
60-
java -jar build/libs/dbAndCsvBatch-*.jar --spring.batch.job.name=DB_TO_CSV --batch.types=2,4 --spring.profiles.active=local
35+
# Generate executable JAR
36+
cd dbAndCsvBatch
37+
../gradlew
38+
39+
# Check generated JAR
40+
ls -l build/libs/
6141
```
6242

63-
- Import data from CSV to DB:
43+
### Execute JAR
6444
```bash
65-
java -jar build/libs/dbAndCsvBatch-*.jar --spring.batch.job.name=CSV_TO_DB --spring.profiles.active=local
66-
```
45+
# DB to CSV export
46+
java -jar build/libs/batch-dbAndCsv*.jar --spring.batch.job.name=DB_TO_CSV --spring.profiles.active=local
6747

48+
# CSV to DB import
49+
java -jar build/libs/batch-dbAndCsv*.jar --spring.batch.job.name=CSV_TO_DB --spring.profiles.active=local
6850

69-
### For Server Environment
70-
- Export data from DB to CSV:
71-
```bash
72-
java -jar build/libs/dbAndCsvBatch-*.jar --spring.batch.job.name=DB_TO_CSV --spring.profiles.active=server
51+
# With custom types (optional)
52+
java -jar build/libs/batch-dbAndCsv*.jar --spring.batch.job.name=DB_TO_CSV --batch.types=2,4 --spring.profiles.active=local
7353
```
7454

75-
- Import data from CSV to DB:
76-
```bash
77-
java -jar build/libs/dbAndCsvBatch-*.jar --spring.batch.job.name=CSV_TO_DB --spring.profiles.active=server
55+
### 💡 Note
56+
> For production use, modify the database configuration in application-server.yml to match your environment settings.
57+
58+
## 📁 Project Structure
59+
```text
60+
src/
61+
├── main/
62+
│ ├── java/
63+
│ │ └── com/example/batch/
64+
│ │ ├── BatchApp.java # Application entry point
65+
│ │ ├── job/
66+
│ │ │ ├── DbToCsvJob.java # DB to CSV job
67+
│ │ │ └── CsvToDbJob.java # CSV to DB job
68+
│ │ ├── logic/ # Business logic
69+
│ │ └── repository/ # Database access
70+
│ └── resources/
71+
│ └── application.yml # Application configuration
72+
└── test/ # Test files
7873
```
79-
With this module, you can seamlessly integrate database and CSV operations into your Spring Boot batch applications. Happy coding! 🎉
74+
75+
## ✨ Highlights
76+
- Multi-Database Setup: H2 for batch metadata, MySQL for business data
77+
- Efficient Data Processing: Bulk operations for better performance
78+
- Dynamic Queries: Customizable data extraction with runtime arguments
79+
- Type-safe SQL: Generated classes with jOOQ

skeletonBatch/README.md

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,59 @@
11
# Skeleton Batch - Spring Batch Template 🚀
22

33
## 🌟 Overview
4-
5-
The SkeletonBatch module is a streamlined template designed to help you create custom batch jobs effortlessly with Spring Batch. Simply add your business logic, and you’ll have a fully operational Spring Boot 3 batch application in no time.
4+
The SkeletonBatch module is a streamlined template designed to help you create custom batch jobs effortlessly with Spring Batch. Simply add your business logic, and you'll have a fully operational Spring Boot 3 batch application in no time.
65

76
---
87

9-
## 🔧 How to Run
8+
## 🔧 How to Run
109

11-
### Step-by-step Instructions
10+
### 1️⃣ Using Gradle (Recommended)
1211
```bash
13-
# Navigate to the skeletonBatch directory
14-
cd skeletonBatch
12+
# Build and Run from project root
13+
./gradlew :skeletonBatch:bootRun
14+
```
1515

16-
# Execute the default task to generate the JAR file
17-
../gradlew
16+
### 2️⃣ Using JAR File
17+
Useful for running with cron jobs or job schedulers. Generate and execute the JAR file as follows:
1818

19-
# Confirm that the Spring Boot JAR file has been generated
20-
ls -ls build/libs/skeletonBatch-*.jar
19+
### Generate JAR
20+
```bash
21+
# Generate executable JAR
22+
cd skeletonBatch
23+
../gradlew
2124

22-
# Run the skeleton batch application
23-
java -jar build/libs/skeletonBatch-*.jar
25+
# Check generated JAR
26+
ls -l build/libs/
2427
```
28+
### Execute JAR
29+
```bash
30+
# Basic execution (requires JDK 21)
31+
java -jar build/libs/batch-skeleton-*.jar
2532

26-
## ✨ Highlights
27-
- Simple Setup: Pre-configured tasks for quick builds.
28-
- Fast Execution: Minimal effort to start your batch job.
29-
- Customizable: Extend the template with your business logic.
33+
# With Java options (if needed)
34+
java -Xms512m -Xmx1g -jar build/libs/batch-skeleton-*.jar
35+
```
3036

37+
## ✨ Highlights
38+
- Simple Setup: Pre-configured tasks for quick builds
39+
- Fast Execution: Minimal effort to start your batch job
40+
- Customizable: Extend the template with your business logic
41+
- H2 Database: In-memory database for zero configuration
42+
43+
## 📁 Project Structure
44+
```text
45+
src/
46+
├── main/
47+
│ ├── java/
48+
│ │ └── com/example/batch/
49+
│ │ ├── BatchApp.java # Application entry point
50+
│ │ ├── job/
51+
│ │ │ └── SampleJob.java # Job configuration
52+
│ │ ├── logic/
53+
│ │ │ └── SampleLogic.java # Business logic
54+
│ │ └── service/
55+
│ │ └── SampleService.java # Service layer
56+
│ └── resources/
57+
│ └── application.yml # Application configuration
58+
└── test/ # Test files
59+
```
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
package com.example.batch;
22

3+
import static org.junit.jupiter.api.Assertions.*;
4+
35
import org.junit.jupiter.api.Test;
46
import org.springframework.boot.test.context.SpringBootTest;
57

6-
import static org.junit.jupiter.api.Assertions.*;
7-
88
@SpringBootTest
99
class BatchAppTest {
1010

11-
@Test
12-
void contextLoads() {
13-
// Confirm that the Spring application context loads without errors
14-
}
11+
@Test
12+
void contextLoads() {
13+
// Confirm that the Spring application context loads without errors
14+
}
1515

16-
@Test
17-
void mainMethodTest() {
18-
// Arrange
19-
String[] args = {"--spring.batch.job.enabled=false"};
16+
@Test
17+
void mainMethodTest() {
18+
// Arrange
19+
String[] args = {"--spring.batch.job.enabled=false"};
2020

21-
// Act
22-
BatchApp.main(args);
21+
// Act
22+
BatchApp.main(args);
2323

24-
// Assert
25-
// No exceptions should occur
26-
}
27-
}
24+
// Assert
25+
// No exceptions should occur
26+
}
27+
}

0 commit comments

Comments
 (0)