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

在尝试启动SpringBoot(v2.4.5)应用程序时遇到一个错误,指出DataSource的url属性未指定,且没有找到内嵌的数据源。问题源于无法确定合适的驱动类。解决方案是检查数据库驱动是否在类路径中,以及数据库连接设置是否正确。在尝试各种方法无果后,删除并重新构建项目,以及重启主库后,应用成功启动。
摘要由CSDN通过智能技术生成

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

问题描述

  
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.4.5)

2023-05-25 15:03:35.450  INFO 14412 --- [           main] com.itheima.Application                  : Starting Application using Java 1.8.0_351 on DESKTOP-6MIV1AR with PID 14412 (E:\mavenprojects\rw_demo\target\classes started by 123 in E:\mavenprojects\rw_demo)
2023-05-25 15:03:35.452  INFO 14412 --- [           main] com.itheima.Application                  : No active profile set, falling back to default profiles: default
2023-05-25 15:03:36.079  INFO 14412 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2023-05-25 15:03:36.085  INFO 14412 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2023-05-25 15:03:36.086  INFO 14412 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.45]
2023-05-25 15:03:36.138  INFO 14412 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2023-05-25 15:03:36.138  INFO 14412 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 584 ms
2023-05-25 15:03:36.173  WARN 14412 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController': Unsatisfied dependency expressed through field 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
2023-05-25 15:03:36.175  INFO 14412 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2023-05-25 15:03:36.186  INFO 14412 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-05-25 15:03:36.196 ERROR 14412 --- [           main] o.s.b.d.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


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).


Process finished with exit code 1

解决方案

搞了一个下午实在没搞明白就把项目删了从构了一遍
主库连接太多还崩了
重启了主库
就启动成功了

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值