Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource…的解决

导读:本篇文章讲解 Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource…的解决,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

一、问题描述

启动项目时报错:

Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
2022-03-18 20:27:05 |ERROR |main |LoggingFailureAnalysisReporter.java:40 |org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter |

***************************
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

二、原因

JDBC的依赖引入项目后,Spring Boot的自动配置试图在配置文件中查找JDBC的相关配置,找不到所以就报错

三、解决

在注解上配置:

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)

作用:取消数据源自动配置

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)//取消数据源自动配置
@ComponentScan({"cn.test"})
public class TestApplication {
    public static void main(String[] args) {
        SpringApplication.run(TestApplication.class, args);
    }
}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/117634.html

(0)
seven_的头像seven_bm

相关推荐

发表回复

登录后才能评论
极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!