解决SpringBoot项目没用数据库但报错:Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured.

在这里插入图片描述

1、在@SpringBootApplication后添加exclude = { DataSourceAutoConfiguration.class }来排除自动配置 :

@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })

2、在application.yml文件中添加排除自动配置

spring:
  autoconfigure:
    exclude: org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐