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
解决方案
搞了一个下午实在没搞明白就把项目删了从构了一遍
主库连接太多还崩了
重启了主库
就启动成功了