我有Spring批处理作业使用的pojo类。
public class DataItem{
String key;
CellType type; //Enum
String name;
private XSSFCell cell; //org.apache.poi.xssf.usermodel.XSSFCell
//getters setters omitted
}
当我尝试运行批处理作业时,我收到以下异常:
java.lang.IllegalArgumentException: Failed to serialize object of type: class org.springframework.batch.core.JobExecution
at org.springframework.util.SerializationUtils.serialize(SerializationUtils.java:49)
at org.springframework.batch.core.repository.dao.MapJobExecutionDao.copy(MapJobExecutionDao.java:50)
at org.springframework.batch.core.repository.dao.MapJobExecutionDao.updateJobExecution(MapJobExecutionDao.java:104)
at org.springframework.batch.core.repository.support.SimpleJobRepository.update(SimpleJobRepository.java:162)
at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:351)
at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:135)
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:128)
at com.excelreader.AppMain.run(AppMain.java:35)
at com.excelreader.AppMain.main(AppMain.java:16)
Caused by: java.io.NotSerializableException: com.excelreader.pojo.DataItem
答案 0 :(得分:4)
DataItem
,其中的所有内容都必须实现Serializable
接口。这就是你获得此例外的原因。