解决SpringBoot项目中遇到的数据库连接yml文件配置问题

今天遇到了一个报错

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.问题分析

        我遇到这个问题时,查了很多网上的办法,有的说加@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})注解; 有的说少了mysql或者JDBC,或者mybatis的依赖,但一一试了都不行。

2.解决办法

        后面发现是因为数据库mysql的版本是8.0.11,而java项目导入的版本是5.7,后面改掉版本依赖后就OK了。

你可能感兴趣的:(数据库,spring,boot,java)