failed to configure a datasource: ‘url‘ attribute is not specified and no em

问题场景

在Spring Boot中整合MySQL、Mybatis进行数据库开发时,按照正常步骤添加了相关数据库的依赖,也进行了必要的数据库配置,结果在项目启动时出现如下异常信息:

复制代码
***************************
APPLICATION FAILED TO START
***************************

Description:

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


Action:

Consider the following:
    If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
    If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
复制代码

解决方法

报错大概意思是未配置DB url ,可是检查发现,配置连接正常,只是这里的数据源采用苞米豆的多数据源

        <!-- 自带数据库连接池,需要注释掉其他的连接池框架 -->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>dynamic-datasource-spring-boot-starter</artifactId>
            <version>2.5.8</version>
        </dependency>

这个插件明确要求需要注释掉其他连接池,为了方便,我关闭了数据源自动装配,主启动类修改如下

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class SpringbootApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringbootApplication.class, args);
    }
}

现在不报错了

posted @   晓枫的春天  阅读(100)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
历史上的今天:
2022-11-18 ClickHouse 语法优化细节(一)
点击右上角即可分享
微信分享提示