寻找资料来源的专案,但我使用的是MongoDB

时间:2018-10-29 16:11:00

标签: java spring mongodb spring-batch

描述:我正在使用MongoDB,它一直在请求数据源。我排除了以下内容:

  exclude=DataSourceAutoConfiguration.class,
  DataSourceTransactionManagerAutoConfiguration.class,
  HibernateJpaAutoConfiguration.class,
  JpaRepositoriesAutoConfiguration.class})

错误:

 Error starting ApplicationContext. To display the conditions report re-run 
 your application with 'debug' enabled.
 2018-10-29 11:03:25.968 ERROR 4676 --- [  restartedMain] 
 o.s.b.d.LoggingFailureAnalysisReporter   : 

说明:

***************************
APPLICATION FAILED TO START
***************************


Parameter 1 of method batchConfigurer in org.springframework.boot.autoconfigure.batch.BatchConfigurerConfiguration$JdbcBatchConfiguration required a bean of type 'javax.sql.DataSource' that could not be found.
- Bean method 'dataSource' not loaded because @ConditionalOnProperty (spring.datasource.jndi-name) did not find property 'jndi-name'
- Bean method 'dataSource' not loaded because @ConditionalOnClass did not find required class 'javax.transaction.TransactionManager'
Action:

Consider revisiting the entries above or defining a bean of type 'javax.sql.DataSource' in your configuration.

1 个答案:

答案 0 :(得分:1)

Spring Boot适用于构建生产级应用程序。当用于构建Spring Batch应用程序时,它需要数据源来保留Spring Batch元数据(请参见BATCH-2704)。

但是您始终可以使用以下任何一种方式:

  • Spring Boot支持的嵌入式数据源(H2,HSQL或Derby),只需将其添加到类路径中即可。此数据源将由Spring Batch自动提取
  • 或提供自定义BatchConfigurer并使用MapJobRepository(请参阅here

希望这会有所帮助。