我正在运行一个批处理示例,它从CSVFile读取数据并将其写入MongoDB。Spring Data MongoDB、Spring Batch starter与下面的详细信息一起添加。
- 应用程序。属性:**
#Spring batch configuration
spring.batch.job.enabled=false
spring.batch.jdbc.initialize-schema=always
#Mongodb configuration
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.database=ntspbms715db
spring.data.mongodb.username=testuser
spring.data.mongodb.password=testuser
我遇到了下面的错误,可以通过在主类中添加@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
来修复。
现在有人能解释一下为什么我会遇到这个问题,以及上面的修复是如何解决这个错误的吗?
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
在主类中添加@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
可修复报告的问题。
1条答案
按热度按时间zd287kbt1#
由于您使用的是带有Sping Boot 的Spring Batch,您需要在应用程序上下文中定义一个数据源bean,这在本文的文档中有所提及,从Spring Batch v5开始,即使没有Spring Boot,也是如此。
此外,以下属性
spring.batch.jdbc.initialize-schema=always
指示Sping Boot 使用Batch表初始化JDBC数据源,但无法找到该表。