Failed to configure a DataSource

简介: Failed to configure a DataSource

1 问题

近日在学习一个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。

2 方法

  1. 找出问题:
    1.1根据提示,翻译问题。
    配置数据源失败:未指定“url”属性,无法配置嵌入式数据源。
    原因:无法确定合适的驱动程序类别。
    即:在应用中没有配置datasource的一些相关属性
  2. 解决方法:

2.1方法一:

找到application.properties,设置驱动程序及相关属性。

2.2方法二:

把spring boot自动初始化DataSource相关的代码禁止掉

在启动类头部声明:

@SpringBootApplication(exclude= DataSourceAutoConfiguration.class)

Exclude:排除此类的AutoConfig,即禁止 SpringBoot 自动注入数据源配置。

3 结语

程序启动可能会面临着各种各样的错误,在该项目学习时,面对依赖的问题,让小编花了很多时间去解决,后续会进行依赖相关的问题进行讲解。在使用时,推荐使用第二种方法,较为简单实用。

目录
相关文章
|
Java 数据库连接 数据库
探究Java中的MyBatis Plus注解 @TableField:灵活处理字段映射与自动填充
在数据库操作中,字段映射和字段填充是开发者经常需要处理的问题。MyBatis Plus作为一款优秀的ORM框架,提供了注解 `@TableField`,能够帮助开发者更加灵活地处理字段映射,以及在特定场景下实现自动填充功能。本文将深入探讨 `@TableField` 注解的用法及其在持久层开发中的应用。
6822 1
|
SpringCloudAlibaba 安全 Java
SpringCloud版本升级后bootstrap.yml配置不生效
SpringCloud版本升级后bootstrap.yml配置不生效
3218 1
|
druid Java 数据库连接
Spring Boot3整合MyBatis Plus
Spring Boot3整合MyBatis Plus
2459 1
|
Java Spring
解决方案 --[restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. ERROR 9680 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter
|
Java 数据库连接 Spring
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could
这个错误通常出现在使用Spring Boot进行数据库连接时。错误信息表明Spring Boot未能配置一个DataSource,因为没有指定'url'属性,并且没有发现默认的数据库连接。
6522 0
|
关系型数据库 MySQL Java
Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could
解决方法: 配置H2数据库或者MySQL数据库,其中配置MySQL解决方法如下: 1、添加 MySQL连接驱动的依赖 Maven工程在pom.xml中添加
3549 0
|
编解码 Java Spring
Spring Boot(14)——使用WebClient
使用WebClient WebClient是Spring WebFlux模块提供的一个非阻塞的基于响应式编程的进行Http请求的客户端工具,从Spring5.0开始提供。Spring Boot应用中添加如下依赖将自动添加Spring WebFlux依赖,从而可以使用WebClient。
5130 0
|
Java 关系型数据库 MySQL
【已解决】SpringBoot 启动报错:Failed to configure a DataSource: ‘url‘ attribute is not specified and no emb
【已解决】SpringBoot 启动报错:Failed to configure a DataSource: ‘url‘ attribute is not specified and no emb
10625 1
|
Java 数据库
Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could
2.报错原因 启动SpringBoot项目时,会自动找数据库配置,但是我们的模块现在不需要操作数据库 3.解决方法 (1)添加上数据库配置 (2)在启动类添加属性,默认不去加载数据库配置(建议
1511 0
Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could
|
安全 Java 数据库
Spring Boot 3 + JWT + Security 联手打造安全帝国:一篇文章让你掌握未来!
`Spring Security`已经成为`java`后台权限校验的第一选择.今天就通过读代码的方式带大家深入了解一下Security,本文主要是基于开源项目[spring-boot-3-jwt-security](https://github.com/ali-bouali/spring-boot-3-jwt-security)来讲解Spring Security + JWT(Json Web Token).实现用户鉴权,以及权限校验. 所有代码基于`jdk17+`构建.现在让我们开始吧!
4341 1
 Spring Boot 3 + JWT + Security 联手打造安全帝国:一篇文章让你掌握未来!

热门文章

最新文章