Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
SpringBoot项目运行报错记录
错误如下:
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 with exit code 0
找了很多文章也改了很久一直没发现自己的错在哪里,错误参考这篇文章第八条。
然后检查发现运行报错的这个模块(没有用到数据库,所以要主启动要配置@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}))也没有引入druid呀,再一仔细瞅,看到了有个接口中使用到一个实体类,属于另一个服务模块。然后引入了提供服务的模块,那个模块中配置了druid。
解决:把当前模块pom引入的服务模块删除,将用到的实体类复制一份到当前模块中配置即可。

浙公网安备 33010602011771号