错误信息
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).
原因其实有几种,我这里是因为使用druid多数据源,没有加上正确的配置导致的:
解决办法就是加上这个配置:
spring:
autoconfigure:
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
同理也可以在启动类加上:
@SpringBootApplication(exclude = {DruidDataSourceAutoConfigure.class})
注:此处只针对配置了druid多数据源的场景,报错的原因还有很多