我用 JdbcTemplate 实现了 ItemReader 。
问题是read()在无限循环中被调用。
public class MyReader implements ItemReader<Col>, InitializingBean {
private JdbcTemplate jdbcTemplate;
private RowMapper<Col> rowMapper;
private String sql;
private DataSource dataSource;
public Col read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException {
Col col = jdbcTemplate.queryForObject(sql,null, rowMapper);
return col;
}
}
Run Code Online (Sandbox Code Playgroud)
Spring批量配置:
<chunk reader="itemReader" writer="itemWriter"
processor="itemProcessor" commit-interval="1" />
<bean id="itemReader"
class="batch.MyReader"
scope="step">
<property name="dataSource" ref="dataSource" />
<property name="sql" value="#{stepExecutionContext[sql]}" />
<property name="rowMapper">
<bean class="batch.ColMapper" />
</property>
</bean>
Run Code Online (Sandbox Code Playgroud) 当我Composite在内部嵌入控件时ViewPart,在文本框和按钮之间添加了一个垂直边距/填充(按钮是另一个复合的一部分),如附图所示.
我该如何删除它?
public class View extends ViewPart {
public static final String ID = "xyyx.view";
public void createPartControl(Composite parent) {
GridLayout layout = new GridLayout(1, false);
parent.setLayout(layout);
Text infoText = new Text(parent, SWT.BORDER);
GridData gridDataInfo = new GridData();
gridDataInfo.horizontalSpan = 1;
gridDataInfo.grabExcessHorizontalSpace = true;
gridDataInfo.horizontalAlignment = GridData.FILL;
infoText.setLayoutData(gridDataInfo);
new NewComposite(parent, SWT.NONE);
}
public class NewComposite extends Composite{
public NewComposite(Composite parent, int style) {
super(parent, style);
GridLayout layout = new GridLayout(1, false);
setLayout(layout);
Button btn = new …Run Code Online (Sandbox Code Playgroud) 我有 Spring 批处理作业使用的 pojo 类。
public class DataItem{
String key;
CellType type; //Enum
String name;
private XSSFCell cell; //org.apache.poi.xssf.usermodel.XSSFCell
//getters setters omitted
}
Run Code Online (Sandbox Code Playgroud)
当我尝试运行批处理作业时,出现以下异常:
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
Run Code Online (Sandbox Code Playgroud)