diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5da5b79..b599916 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build and Test with jOOQ and Docker +name: Build and Test on: pull_request: diff --git a/README.md b/README.en.md similarity index 73% rename from README.md rename to README.en.md index a19ba81..6b0d175 100644 --- a/README.md +++ b/README.en.md @@ -8,34 +8,25 @@ ![Java 21](https://img.shields.io/badge/Java-21%2B-blue) [![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-CC2233.svg)](https://opensource.org/licenses/Apache-2.0) -## 🔍 Overview / 概要 +## 🔍 Overview This repository serves as a **Spring Batch Starter Kit**, specifically tailored for **Spring Boot 3** and **Spring Batch 5**. It streamlines batch job development by leveraging the **latest features** and ensuring full compatibility with Spring Boot 3. Whether you’re upgrading from **Spring Boot 2** or starting a new project, this starter kit enables you to **harness the enhanced capabilities** of Spring Batch with ease. -このリポジトリは、Spring Boot 3 と Spring Batch 5 の最新機能を活用して、バッチ処理開発を効率化するためのスターターキットです。動作する事が保証されたテンプレート上に業務ロジックを追加するだけで、簡単にバッチ処理を構築できます。Spring Boot 2 からの移行や新規プロジェクトにおいて、すぐに最新のバッチフレームワークを活用できます。 - -### 📝 Key Highlights / 主な特徴 +### 📝 Key Highlights - **Skeleton Batch Framework**: Quickly develop custom batch jobs with minimal setup. - **DB to CSV Batch**: Export data from MySQL to CSV files seamlessly, with runtime arguments for dynamic WHERE clauses and flexible output configurations. - **CSV to DB Batch**: Import CSV data into MySQL efficiently with bulk operations and error handling. - -- **スケルトンバッチ**: 業務ロジックを追加するだけでバッチを簡単に構築する事が可能です。 -- **DB to CSVバッチ**: MySQLデータをCSVファイルに簡単に出力できます。実行時引数を利用した動的なWHERE句や柔軟な出力設定に対応しています。 -- **CSV to DBバッチ**: CSVデータをMySQLに効率的に取り込みます。バルク処理機能を備えています。 - ### Reusability / 再利用性 This kit is highly adaptable. By simply updating the database connection settings and modifying the CSV column definitions to match your specific business needs, you can immediately start using it for your projects. -DB接続設定やCSVのカラム定義を業務仕様に合わせて変更するだけで、すぐにプロジェクトで利用できます。シンプルなテンプレートを基に、業務ロジックを追加するだけで、効率的に高機能なバッチ処理を構築できます。 - --- -## 💡 Key Features / 特徴 +## 💡 Key Features ### Batch Development Made Simple - **Spring Batch Framework**: Streamlined job and step management. @@ -53,10 +44,11 @@ DB接続設定やCSVのカラム定義を業務仕様に合わせて変更する ### Future-Proof Design - **Skeleton Batch Framework**: A template for creating new batch jobs. - **Pre-configured Docker Environment**: Quickly set up a local MySQL database. +- **CI/CD**: Achieve Continuous Integration and Continuous Delivery with Github Actions. --- -## 🗂️ Project Structure / プロジェクト構成 +## 🗂️ Project Structure ```text . ├── gradlew @@ -79,7 +71,7 @@ DB接続設定やCSVのカラム定義を業務仕様に合わせて変更する └── test ``` -## 🛠️ Getting Started / はじめに +## 🛠️ Getting Started ### 1. Clone the repository ```bash @@ -123,7 +115,7 @@ java -jar build/libs/dbAndCsvBatch-*.jar --spring.batch.job.name=CSV_TO_DB --spr #### 🎉 **With this Spring Batch Starter Kit, you can focus on your business logic while the framework handles the heavy lifting.** **Happy coding!** 🚀 -## 📄 License / ライセンス +## 📄 License This project is licensed under the **[Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0)**. Copyright © 2024 KINTO Technologies Corporation \ No newline at end of file diff --git a/README.ja.md b/README.ja.md new file mode 100644 index 0000000..35efc33 --- /dev/null +++ b/README.ja.md @@ -0,0 +1,122 @@ +### 日本語用README (`README.ja.md`) + +# Spring Batch 5 Starter + +**コピペで即完成! Spring Batch 5** 🚀 + +[![GitHub stars](https://img.shields.io/github/stars/KTC-YoheiMiyashita/SpringBoot3BatchStarter?style=social)](https://github.com/KTC-YoheiMiyashita/SpringBoot3BatchStarter/stargazers) +[![Build](https://github.com/kinto-technologies/SpringBoot3BatchStarter/actions/workflows/build.yml/badge.svg)](https://github.com/kinto-technologies/SpringBoot3BatchStarter/actions/workflows/build.yml) +![Java 21](https://img.shields.io/badge/Java-21%2B-blue) +[![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-CC2233.svg)](https://opensource.org/licenses/Apache-2.0) + +## 🔍 Overview + +このリポジトリは、**Spring Boot 3** と **Spring Batch 5** のために特化した**Spring Batchスターターキット**です。 +最新機能を活用し、Spring Boot 3との完全な互換性を持つことで、バッチジョブ開発を効率化します。 +**Spring Boot 2** からの移行や新規プロジェクトで、**Spring Batchの強化された機能**を簡単に活用できます。 + +### 📝 Key Highlights +- **スケルトンバッチフレームワーク**: 最小限の設定でカスタムバッチジョブを簡単に開発できます。 +- **DB to CSV バッチ**: MySQLデータをCSVファイルにエクスポート。動的なWHERE句や柔軟な出力設定に対応しています。 +- **CSV to DB バッチ**: CSVデータをMySQLに効率的にインポートします。バルク処理とエラーハンドリング機能を備えています。 + +### 再利用性 +このキットは非常に適応性があります。データベース接続設定を更新し、CSVのカラム定義を業務要件に合わせて変更するだけで、すぐにプロジェクトに利用できます。 + +--- + + + +## 💡 特徴 + +### Batch Development Made Simple +- **Spring Batch フレームワーク**: ジョブとステップの管理を効率化。 +- **JOOQ ORM**: SQLライクなクエリ記述とエンティティ生成機能。 +- **OpenCSV 統合**: CSVファイルの簡単な取り扱い。 +- **マルチデータベースサポート**: + - H2 : バッチメタデータ管理にH2 + - MySQL : 業務データ処理にMySQL + +### 柔軟性と最適化 +- **動的な設定**: 環境ごとの設定(ローカル/サーバー)をプロファイルで管理。 +- **カスタマイズ可能なバッチ**: 実行時の引数で複数のジョブを動的に実行。 +- **Google Java Format**: Spotlessを使用した自動コード整形。 + +### 将来に向けた設計 +- **スケルトンバッチフレームワーク**: 事前設定されたDocker環境。 +- **事前設定されたDocker環境**: ローカルのMySQLデータベースを迅速にセットアップ。 +- **CI/CD**: Github Actions で「継続的インテグレーションと継続的デリバリーを実現。 + +--- + +## 🗂️ プロジェクト概要 +```text +. +├── gradlew +├── settings.gradle +├── compose.yaml +├── init-scripts +│ ├── 1-create-table.sql +│ └── 2-insert-data.sql +├── dbAndCsvBatch +│ ├── README.md +│ ├── build.gradle +│ └── src +│ ├── main +│ └── test +└── skeletonBatch + ├── README.md + ├── build.gradle + └── src + ├── main + └── test +``` + +## 🛠️ はじめに + +### 1. リポジトリをクローンする +```bash +git clone https://github.com/kinto-technologies/SpringBoot3BatchStarter.git +``` + +### 2. スケルトンバッチをビルドする +```bash +cd skeletonBatch +../gradlew +``` + +### 3. スケルトンバッチを実行する +```bash +java -jar build/libs/skeletonBatch-*.jar +``` + +### 4. MySQLデータベースを設定する(Docker) +```bash +docker compose up -d +``` + +### 5. DB と CSV バッチジョブをビルドする +```bash +cd ../dbAndCsvBatch +../gradlew +``` + +### 6. DB to CSV バッチを実行する +```bash +java -jar build/libs/dbAndCsvBatch-*.jar --spring.batch.job.name=DB_TO_CSV --spring.profiles.active=local +``` + +### 7. CSV to DB バッチを実行する +```bash +java -jar build/libs/dbAndCsvBatch-*.jar --spring.batch.job.name=CSV_TO_DB --spring.profiles.active=local +``` + +> **注意**: ステップ4を実行する前にDockerがインストールされていて、実行中であることを確認してください。 + +#### 🎉 このSpring Batchスターターキットを使えば、フレームワークが重い作業を引き受ける間に、あなたはビジネスロジックに集中できます。 +**楽しいコーディングを!** 🚀 + +## 📄 ライセンス + +このプロジェクトは、**[Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0)** の下でライセンスされています。 +Copyright © 2024 KINTO Technologies Corporation \ No newline at end of file diff --git a/dbAndCsvBatch/src/test/java/com/example/batch/service/CsvToDbServiceTest.java b/dbAndCsvBatch/src/test/java/com/example/batch/service/CsvToDbServiceTest.java index a4d08d9..3a4ac11 100644 --- a/dbAndCsvBatch/src/test/java/com/example/batch/service/CsvToDbServiceTest.java +++ b/dbAndCsvBatch/src/test/java/com/example/batch/service/CsvToDbServiceTest.java @@ -66,7 +66,7 @@ void setUp() throws IOException { "2024-12-07T09:46:07" }); } - log.info("Temporary CSV file content written successfully."); + log.info("Temporary CSV file created at: {}", tempCsvFile.getAbsolutePath()); } @Test