彻底解决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
彻底解决Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource
- 错误描述:
- 错误原因:
- 解决办法
错误描述:
2022-08-19 09:56:55.641 WARN 47976 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: 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
2022-08-19 09:56:55.645 INFO 47976 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2022-08-19 09:56:55.657 INFO 47976 --- [ main] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-08-19 09:56:55.743 ERROR 47976 --- [ 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 classAction: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
错误原因:
springboot自动装配,一开始是直接默认连接数据库的即错误中提示的datasource,而我这里并没有连接数据库,没有给它datasource,所以就会找不到datasource,那么就出现了错误。
解决办法
将主启动类的注解@SpringBootApplication
修改为@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})
忽略到数据库连接即可。
更多推荐
彻底解决Failed to configure a DataSource: ‘url‘ attribute is not specified and no em
发布评论