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

编程入门 行业动态 更新时间:2024-10-10 11:20:49

<a href=https://www.elefans.com/category/jswz/34/1762264.html style=彻底解决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

本文发布于:2024-02-27 19:06:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1766147.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:彻底解决   configure   Failed   DataSource   datasource

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!