2013-02-14 36 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

相關問題