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

一、错误如下

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

二、错误的原因

项目启动是出现该错误的原因,[email protected]该注释会有数据库的自动配置,但在项目配置文件中没有找到相关的配置导致的。

三、解决方法

如果是配置错误修改配置就可以,如果是项目本身不需要数据库可以在@SpringBootApplication,加上exclude=DataSourceAutoConfiguration.class,排除数据库的自动配置类就可以了 ,如下所示:

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