Java MongoItemReader:如何处理自定义字段?
spring batch提供的MongoItemReader具有方法设置字段:Java MongoItemReader:如何处理自定义字段?,java,spring,mongodb,spring-batch,Java,Spring,Mongodb,Spring Batch,spring batch提供的MongoItemReader具有方法设置字段: public void setFields(java.lang.String fields) JSON defining the fields to be returned from the matching documents by MongoDB. Parameters: fields - JSON string that identifies the fields to sort by. 我有一门课: pu
public void setFields(java.lang.String fields)
JSON defining the fields to be returned from the matching documents by
MongoDB.
Parameters:
fields - JSON string that identifies the fields to sort by.
我有一门课:
public class Raw {
private String id;
private String version;
private String client;
private String appName;
private String os;
// getters & setters
}
我在mongodb中有这样的数据:
{
"_id" : ObjectId("58a3373e1e041a1191cd5d6d"),
"Version" : "123",
"Client" : "SomeClient",
"MobilePlatform" : "iphoneos",
"AppName" : "MyAppName",
"Os" : "Windows 10"
}
-正如您所看到的,所有字段名称都以大写字母开头。
现在我需要用spring批处理从mongo读取数据。
我需要以某种方式将原始类中的字段映射到mongo DB中的数据,以便能够获取数据。
我怀疑setFields方法仅适用于此类情况。
但我对mongo和spring batch也比较陌生,
所以我想问一下如何做到这一点?
我应该将哪个JSON放入setFields方法中?
或者可能还有其他选择
非常感谢您的帮助。我在文档中找到了答案: @可以使用字段注释,并且可以正常工作