文章目录
  • 小结
  • 问题
  • 解决
  • 参考


小结

Spring Boot报错:没有配置数据源(url属性未设置),进行解决。

问题

Spring Boot报错:

ERROR 2024-08-28 17:24:43.734 [main] - 

***************************
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 (the profiles default are currently active).
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.

解决

具体原因,项目调用FeignClient数据源,因此不需要配置数据源,在主应用里关闭数据源的设置。将注@SpringBootApplication修改如下:

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
  • 1.

以上,问题解决。

参考

 stackoverflow: Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured