Wondercease

浙ICP备2022017321号

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

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

@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
1
方案二
在application.yml文件中添加排除自动配置

spring:
autoconfigure:
exclude: org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
1
2
3
方案三
检查pom依赖有没有直接或者间接的导入了下面的依赖
spring-boot-starter-jdbc

方案四

前面三种方案都是项目不用数据库的情况下,如果用数据库还报这个错基本就是四大参数没配置:

spring:
datasource:
url: jdbc:mysql://localhost:3306/xxxx
username: root
password: root
driver-class-name: com.mysql.jdbc.Driver

发表评论

您的电子邮箱地址不会被公开。