Edsel
Edsel

Reputation: 45

Project looking for a datasource but I am using MongoDB

Description: I am using MongoDB and it keeps asking for a datasource. I have excluded the following:

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

error:

 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   : 

Description:

***************************
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.

Upvotes: 0

Views: 453

Answers (1)

Mahmoud Ben Hassine
Mahmoud Ben Hassine

Reputation: 31600

Spring Boot is intended for building production grade applications. When it is used to build a Spring Batch application, it requires a data source to persist Spring Batch meta-data (See BATCH-2704).

But you can always use either:

  • an embedded datasource supported by Spring Boot (H2, HSQL or Derby) by just adding it to the classpath. This data source will be picked up automatically by Spring Batch
  • or provide a custom BatchConfigurer and use the MapJobRepository (See here)

Hope this helps.

Upvotes: 1

Related Questions