mysql-connector-java版本匹配问题:ERROR DruidDataSource - create connection SQLException,Day_45

mysql安装的是:8.0.23,启动项目后发现报错连接不上数据库

报错信息:

Druid-ConnectionPool-Create-150783284] ERROR DruidDataSource - create connection SQLException, url: jdbc:mysql://localhost:3306/carefree?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false, errorCode 0, state 08001
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.

报错原因:

低版本的mysql-connector-java和高版本的mysql不匹配

解决方案:

升级mysql-connector-java版本

<!-- MySql -->
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>5.1.49</version>
            </dependency>