一、问题描述
启动项目时报错:
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