Failed to configure a DataSource: 'url' attribute is not specified and no embedde
1、异常错误日志
***************************
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).
Process finished with exit code 1
2、分析原因解决
这个错误通常发生在使用Spring框架的应用程序中,当应用程序尝试连接数据库时,但无法找到正确的数据库连接URL时会出现此错误。
方案一:
在springboot启动类中加上
@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})
方案二:
在配置文件中配置数据库的信息
spring:
application:
name: api-indeximg
datasource:
username: root
password: 13177936413qq
url: jdbc:mysql://localhost:3306?fmmmall?serverTimeZone=UTC
driver-class-name: com.mysql.cj.jdbc.Driver
希望以上内容对你们有所帮助