在扩展具有台阶的mongoItemReader时,所有字段都充满空值,但是如果使用mongoItemReader,则一切都可以
我正在与MongoDB数据库一起在春季批处理中使用本地分区。 我创建了一个扩展MongoItemReader的订阅程序。
public class SubscriptionReader<T> extends MongoItemReader<T> implements InitializingBean {
private MongoOperations template;
private Query query;
private String queryString;
// and other private fields with setter methods and custom implementation of DoPageRead method.
这是JobConfig类:
@Configuration
@EnableBatchProcessing
public class JobConfig
{
...
@Bean
@StepScope
public SubscriptionReader<Subscription> reader()
{
Map<String, Sort.Direction> sorts = new HashMap<>();
sorts.put("_id", Sort.Direction.ASC);
SubscriptionReader<Subscription> reader = new SubscriptionReader<>();
reader.setCollection("subscription");
reader.setQuery(query(null, null, null));
reader.setTemplate(template);
reader.setName("reader");
reader.setTargetType(Subscription.class);
reader.setPageSize(20000000);
return reader;
}
如果我用MongoItemReader替换订阅者,一切都可以,但是当Spring创建分区步骤时,所有字段的订阅程序都是无效的。 编辑: 当我的课程呼叫的后propertiesset方法并检查无效性时,我会得到异常。如果我删除它,我将获得一个NullPoInterException。 预先感谢您的时间和关注。
I'm using local partitioning in the spring batch along with the MongoDb database.
I created a SubscriptionReader that extends MongoItemReader.
public class SubscriptionReader<T> extends MongoItemReader<T> implements InitializingBean {
private MongoOperations template;
private Query query;
private String queryString;
// and other private fields with setter methods and custom implementation of DoPageRead method.
This is JobConfig class:
@Configuration
@EnableBatchProcessing
public class JobConfig
{
...
@Bean
@StepScope
public SubscriptionReader<Subscription> reader()
{
Map<String, Sort.Direction> sorts = new HashMap<>();
sorts.put("_id", Sort.Direction.ASC);
SubscriptionReader<Subscription> reader = new SubscriptionReader<>();
reader.setCollection("subscription");
reader.setQuery(query(null, null, null));
reader.setTemplate(template);
reader.setName("reader");
reader.setTargetType(Subscription.class);
reader.setPageSize(20000000);
return reader;
}
If I replace SubscriptionReader with MongoItemReader, everything is ok but all fields of SubscriptionReader are null when spring creates partitioned steps.
Edit:
I get exception when afterPropertiesSet method of my class calls and it checks for nullability. If I remove that, I'll get a nullPointerException.
Thanks in advance for your time and attention.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论