Spring Batch 6 でクラス構成が変わった?[プログラミング]
(2026-05-09 10:43:09) by shinoda


Java のバッチ処理を Spring Batch フレームワークを使って作成しようと思って、サイトの情報をググりながら作業してたんだけど、Spring Batch の「chunk(チャンク)」モデルのバッチを作成しようとしていきなり問題が(^^;;;
org.springframework.batch.item 以下のクラスが import できないのである。

Maven のローカルキャッシュ(.m2)の下の repository\org\springframework\batch を見てみると、

spring-batch-bom
spring-batch-core
spring-batch-infrastructure
spring-batch-test

しかないやん。今回、Spring Batch は最新バージョンの 6.0.3 を使っているので、クラスの構成変わったんかな?
ググってみたけど、org.springframework.batch.item というのがある前提の記事ばっかで・・・

結局、item は org.springframework.batch.infrastructure の下にあった。

エラーが出ている行で「インポートの構成」を選択。

<画像:20260508_spring1.jpg>

「インポートする型の選択」で「org.springframework.batch.infrastructure.item.ParseException」を選択。
(「org.springframework.batch.item.ItemReade」のエラー行を指定しているので「org.springframework.batch.infrastructure.item.ItemReader」が表示されそうなもんだが、よくわからん。こういうもの?)

<画像:20260508_spring2.jpg>

これで、

import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.NonTransientResourceException;
import org.springframework.batch.item.ParseException;
import org.springframework.batch.item.UnexpectedInputException;

が、

import org.springframework.batch.infrastructure.item.ItemReader;
import org.springframework.batch.infrastructure.item.NonTransientResourceException;
import org.springframework.batch.infrastructure.item.ParseException;
import org.springframework.batch.infrastructure.item.UnexpectedInputException;

に置き換わって幸せになった。

しかし、この先も最新版を使ってる故の苦労がありそうだ。

エロい人たち、早く Spring Batch 6 を使った記事を書いてほしいです。

コメント投稿
次の記事へ >
< 前の記事へ
TOPへ戻る

Powered by
MT4i 3.0.8