【报错】Failed to configure a DataSource: ‘url‘ attribute is not specified and no em....
2026/9/19 13:33:00 网站建设 项目流程

一、项目启动报错

*************************** 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 withexitcode1

二、解决思路

  1. 初步看报错以为是数据库挂了,结果用navicat连接了一下线上数据库没问题。
  2. 我什么配置都没动、代码也没改,检查了一下数据库配置的也没问题,所以代码和配置的问题就被我排除了。
  3. 在网上搜了一下在启动类上可以加上exclude=DataSourceAutoConfiguration.class,则:@SpringBootApplication(exclude= DataSourceAutoConfiguration.class)。(试了一下,果然不靠谱。)

三、报错原因

经排查,因为报错出现的位置是springboot启动报错,所以我猜想应该还是跟配置相关。

  1. 重新勾选开发环境。
  2. 重新update一下项目。
  3. 成功解决~~~

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询