SpirngBoot 错误(1)
对于出现该错:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-11-18 17:20:06.572 ERROR 23284 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
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).
进程已结束,退出代码为 1
一般是引入了对数据库的配置依赖项,如我引入了mybatis,但没有在配置文件中设置数据源等配置,重新加上常用配置即可:
# 数据库驱动:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
# 数据源名称
spring.datasource.name=defaultDataSource
# 数据库连接地址
spring.datasource.url=jdbc:mysql://localhost:3306/blue?serverTimezone=UTC
# 数据库用户名&密码:
spring.datasource.username=root
spring.datasource.password=root