springboot启动错误:‘url‘ attribute is not specified and no embedded datasource could be configured

错误描述:
在对一个旧项目进行前后端分离重构时,将旧项目的某个接口实现代码,移植到重构的新项目上,结果启动时报如下错误

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

错误分析:
在对该问题进行一番搜索,并结合自身对项目的改动部分进行分析之后,发现问题出现在pom依赖部分:移植的代码中,有一个类的使用需要导入旧项目自己封装的依赖jar包,但是使用 alt+enter 导入依赖后,与新项目中原有的依赖发生了冲突,于是导致项目启动时报错。

<dependency>
    <groupId>cn.oasishospitals</groupId>
    <artifactId>oasishospitals-role-api</artifactId>
    <version>20.06.26-SNAPSHOT</version>
    <scope>compile</scope>
</dependency>
<dependency>
    <groupId>cn.oasishospitals</groupId>
    <artifactId>oasishospitals-role-api</artifactId>
    <version>20.06.26-SNAPSHOT</version>
</dependency>

解决方案:
将重复导入的依赖直接删除即可。

后续补充:
在又一次因为类似的操作,而导致同样的错出现后,发现即使只保留其中一个依赖(依赖不重复),启动时依然上述错误,而将该依赖彻底删除,虽不再报上述错误,但需要该依赖存在才能使用的类却无法正常使用,目前该问题尚未找到具体原因。
因进度原因,没有在此处纠结,而是选择了其它的实现方式,该问题先暂时先记下,若之后再遇到此问题时再进一步分析研究。

你可能感兴趣的:(项目实战,java,spring,boot,bug)