Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could

Spring boot的Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured.异常

这个是我在自学时第一个运行的程序出现的异常 ,网上有很多解决方法~比较常见
我的解决方法是在main上加
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could

问题的关键是没有配置数据源,项目启动时会自动回查数据源,所以找不到就报了错。

如果配置了数据源,main上只加注解也不会报错