【问题标题】:Project looking for a datasource but I am using MongoDB项目正在寻找数据源,但我正在使用 MongoDB
【发布时间】:2019-04-02 15:02:27
【问题描述】:

描述:我正在使用 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.

【问题讨论】:

  • 你能给我们看看你的 pom 和你的属性文件吗?

标签: java spring mongodb spring-batch


【解决方案1】:

Spring Boot 旨在构建生产级应用程序。用于构建 Spring Batch 应用程序时,需要数据源来持久化 Spring Batch 元数据(参见BATCH-2704)。

但您可以随时使用:

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

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-03
    • 2020-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-17
    • 1970-01-01
    • 2023-03-10
    相关资源
    最近更新 更多