springboot启动报Description: Failed to configure a DataSource: ‘url‘ attribute is not specified and no

我就是我 2022-12-11 15:13 241阅读 0赞

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

Disconnected from the target VM, address: ‘127.0.0.1:54478’, transport: ‘socket’

原因:因为依赖别的项目的pom文件导入了mybatis的数据源依赖,项目启动时会进行自动配置,而我的这个项目没有使用数据源相关操作,所以报了异常。

解决:在启动类注解上加上 exclude = DataSourceAutoConfiguration.class

  1. @SpringBootApplication(exclude = DataSourceAutoConfiguration.class)

另一个解决办法是也可以在pom文件中进行排除。

发表评论

表情:
评论列表 (有 0 条评论,241人围观)

还没有评论,来说两句吧...

相关阅读