2016-03-03 124 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{ 

}