SpringBoot 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
错误描述
***************************
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).
错误原因
未对MyBatis
进行配置
解决方案
若无需使用MyBatis,删除pom.xml
中MyBatis依赖
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.4</version>
</dependency>
否则在application.yaml
中对MyBatis进行配置
mybatis:
type-aliases-package: com.spring.boot.bean
mapper-locations: classpath:mapper/*.xml
上述配置中com.spring.boot.bean
为实体类包名,mapper-locations
的mapper
目录在src/main/resources
目录下,