I am developing Spring Batch - MongoDB to XML
example. In this example, when I run the main method I see the below error is cominng. Please guide on the below error
Thank you @Sergio, it was great help from you, but below configuration works.
<bean id="mongodbItemReader" class="org.springframework.batch.item.data.MongoItemReader">
<property name="template" ref="mongoTemplate" />
<property name="collection" value="report" />
<property name="targetType" value="com.mkyong.model.Report" />
<property name="query" value="{'_id':{$gt:0} }" />
<property name="sort">
<util:map>
<entry key="id" value="#{T(org.springframework.data.domain.Sort.Direction).ASC}" />
</util:map>
</property>
</bean>
The only problem I see, nothing is getting write into the XML file. I will raise a separate question for this issue.
Note: The main reason of this error is you need to set <property name="targetType" value="com.mkyong.model.Report" />
this property correctly.
You can also refer: http://www.mkyong.com/spring-batch/how-to-convert-date-in-beanwrapperfieldsetmapper/ as another solution.
As the error points out, you need to set the "type" property on your "mongodbItemReader" bean.
See MongoItemReader javadoc.
Example:
<bean id="mongodbItemReader" class="org.springframework.batch.item.data.MongoItemReader">
<property name="template" ref="mongoTemplate" />
<property name="collection" value="report" />
<property name="targetType" value="Report.class" />
</bean>
You might need to specify the package name in the value (I haven't tried it).