且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Spring Batch中发送自定义对象作为Job参数?

更新时间:2023-09-08 08:06:40

在此JobParameter发送的原因. -无法投射到组织springframework-batch-core-jobparameter/31625130#31625130>问题.关于该问题,您有几种想法.

I have summarized reasons why you cannot send object as JobParameter in this question. There are couple of ideas on that question how you can do it.

TL:TR:我认为***的方法是在数据库中创建表,该表存储对象并将该记录的ID作为JobParameter传递,或者将Object序列化为json并将其作为String传递给Job作为JobParameter.如果选择第二种方法,请注意string_val以varchar 250的形式存储在数据库中,因此限制为250个字符.

TL:TR: I think best way would be either to create table in DB which stores Object and pass id of that record as JobParameter or to serialize Object to json and pass it as String in job as JobParameter. If you go with second option be aware that string_val is stored in DB as varchar 250 so limit is 250 characters.