新建Springboot 报错: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
Reason: Failed to determine a suitable driver class)
解决办法
1、在主启动的注解排除数据库配置
// An highlighted block
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
public class ComsumerMain {
public static void main(String[] args) {
SpringApplication.run(ComsumerMain .class, args);
}
}
2、增加相关数据库配置
datasource:
type: com.alibaba.druid.pool.DruidDataSource # 当前数据源操作类型
driver-class-name: org.gjt.mm.mysql.Driver # mysql驱动包
url: jdbc:mysql://localhost:3306/db?useUnicode=true&characterEncoding=utf-8&useSSL=false
username: root
password: root