Failed to configure a DataSource:‘url’attribute is not specified and no embedded的解决方法

编程入门 行业动态 更新时间:2024-10-09 20:21:37

Failed to configure a DataSource:‘url’attribute is not specified and no embedded的<a href=https://www.elefans.com/category/jswz/34/1770089.html style=解决方法"/>

Failed to configure a DataSource:‘url’attribute is not specified and no embedded的解决方法

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

问题详情如下:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-06-03 15:48:45.482 ERROR 3056 --- [           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

错误说明:未能配置数据源:未指定“url”属性,无法配置嵌入的数据源。
解决方法
方法1:在 pom.xml 配置文件中,加入JDBC 依赖包,在启动配置文件时 ,Spring Boot 的自动装配机制就会去配置文件中找,相关的数据库的连接配置信息,如果找不到则抛出异常信息

 <dependency><groupId>org.springframework</groupId><artifactId>spring-jdbc</artifactId>
</dependency>

方法2:DataSourceAutoConfiguration会自动加载.可以排除此类的自动配置,在启动类中加入

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)

修改配置后,测试是否能正常启动,如下图所示:

更多推荐

Failed to configure a DataSource:‘url’attribute is not specified and no embedded

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

发布评论

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

>www.elefans.com

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