2016-03-03 91 views
0

我在我的應用程序中使用了Spring批處理框架,其中我已成功集成了Spring批處理管理器。當我試圖爲JdbcTemplate創建bean時。它給我以下錯誤:在Spring批處理和Spring批次管理集成中DataSource衝突

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceInitializer': Invocation of init method failed; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [javax.sql.DataSource] is defined: expected single matching bean but found 2: dataSource,phoenixDataSource 

其中「數據源」是使用Spring Batch的管理員,而「phoenixDataSource」是由我創建的。我如何區分兩者,有沒有辦法將@Qualifier提供給BatchAdmin使用過的dataSource。

回答

0

我的建議是,您將重命名爲dataSource,並在Spring批次管理員Bean之前首先加載您的應用程序上下文。

0

除了@Ashish之外,您可以使用限定符來引用您要使用的數據源。

@Qualifier("phoenixDataSource") 
private Datasource datasource; 

@Qualifier("phoenixDataSource") 
public class PhoenixDatasource{ 

}