Spring Boot报错:没有配置数据源(url属性未设置)

文章目录

  • 小结
  • 问题
  • 解决
  • 参考

小结

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).	

解决

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

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })

以上,问题解决。

参考

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

你可能感兴趣的:(programming,Spring,spring,boot,后端,java)