Nie*_*Wet 4 java spring listener spring-batch
当使用ItemWriteListener
Spring Batch中的(或类似的)时,处理被检查的异常的正确方法是什么?是侦听器的委托?
例如:
public class MyClass implements ItemWriteListener<MyDTO> {
// fields and constructor omitted
@Override
public void beforeWrite(List<MyDTO> items) {
try {
repository.loadAll(); // <-- Throws some checked exception
} catch (Exception e) {
// What to do here?
}
}
// other methods omitted
}
Run Code Online (Sandbox Code Playgroud)
我该如何处理这个例外?以下是一些想法:
RuntimeException
MyDTO
项目上设置一些指示以指示失败当然,我不能抛出已检查的异常,因为它未在ItemWriteListener
接口上声明.
归档时间: |
|
查看次数: |
3838 次 |
最近记录: |