2013-02-14 75 views
0

在执行我的工作,我得到异常下面没有定义命名为“springbatch.readerDataSource”豆

无法解析参考豆“springbatch.readerDataSource”而设置的bean属性“数据源”;嵌套的例外是org.springframework.beans.factory.NoSuchBeanDefinitionException:没有名为 'springbatch.readerDataSource' 豆在org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference定义 (BeanDefinitionValueResolver.java:329)

注 - 我没有创建单独的阅读器文件。只需使用JdbcCursorItemReader。

我的配置文件

<bean id="itemReader" 
     class="org.springframework.batch.item.database.JdbcCursorItemReader" scope="step"> 
     <property name="dataSource" ref="springbatch.batchDataSource"/> 
     <property name="sql" 
        value= 
        "select Cust_Id from Customer "/> 
     <property name="rowMapper"> 
      <bean class="com.insurance.premiumrecalculation.batch.CustDto" /> 
     </property> 
    </bean> 

    <bean id="policy.premium.recalculation.PremiumRecalculationWriter" 
     class="com.insurance.premiumrecalculation.batch.PremiumRecalculationProcessWriter" scope="step"/> 

    <batch:job id="policy.job.premiumRecalculation" 
     job-repository="springbatch.jobRepository" parent="springbatch.job.baseJob"> 

     <batch:step id="policy.step.premiumrecalculation" parent="springbatch.step.baseStep"> 
      <batch:tasklet allow-start-if-complete="false" transaction-manager="powTransactionManager">         
       <batch:chunk commit-interval="10"      
        reader="itemReader" 
        writer="policy.premium.recalculation.PremiumRecalculationWriter"/>      
      </batch:tasklet> 
     </batch:step> 
    </batch:job> 

在此先感谢

回答

0

这个错误的根源是以下行:

<property name="dataSource" ref="springbatch.batchDataSource"/> 

,这意味着你需要使用ID的bean定义“springbatch.batchDataSource”配置为您的环境的数据源,似乎不存在。您可以使用以下内容作为模板;不要忘记提供您的数据库驱动程序和连接信息。

<bean id="springbatch.batchDataSource" class="org.apache.commons.dbcp.BasicDataSource"> 
    <property name="driverClassName" value="org.hsqldb.jdbcDriver" /> 
    <property name="url" value="jdbc:hsqldb:mem:testdb" /> 
    <property name="username" value="sa" /> 
    <property name="password" value="" /> 
</bean> 
+0

在我的Spring配置文件“springbatch.batchDataSource”已cofigured。还有我的XML我使用springbatch.batchDataSource但投掷“springbatch.readerDataSource”例外。 – Smita 2013-02-18 06:01:28

相关问题