我有这样的配置:
<bean id="reader" class="com.company.MyReader" scope="prototype">
<property name="dataSource" ref="dataSource"/>
<property name="sql" value="select * from dummy"/>
<property name="rowMapper" ref="rowMapper"/>
<property name="verifyCursorPosition" value="false"/>
</bean>
<bean id="rowMapper" class="com.company.MyRowMapper>
<property name="firstName" value="hillary/>
</bean>org.springframework.jdbc.core.RowMapper的MyRowMapper实现
org.springframework.batch.item.database.JdbcCursorItemReader的MyReader扩展
在super.doRead()中调用MyReader,这将返回MyRowMapper对象。然而,这些对象并没有被容器自动释放-属性firstName返回为null。请注意,MyReader正在按预期由Spring容器自动处理。
需要做些什么才能让RowMapper自动完成?
非常感谢!
发布于 2012-08-30 13:09:26
您是否注释过MyReader以通知Spring它需要MyRowMapper的实例?
public class com.company.MyReader{
@Autowired
private MyRowMapper mapper;
public void setMyRowMapper(MyRowMapper newMapper){
this.mapper = newMapper;
}
}https://stackoverflow.com/questions/11331018
复制相似问题