报错内容
***************************
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依赖,但是没有配置数据源
解决方法
不需要用到数据库
在启动类中排除跟数据库相关的操作
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
需要用到数据库
在application.yml中配置数据源即可
spring: datasource: url: jdbc:mysql://192.168.108.75/test username: root password: abcd1234 driver-class-name: com.mysql.cj.jdbc.Driver