Home > Java > javaTutorial > body text

How to solve the problem of com.mysql.cj.jdbc.Driver becoming popular in yml file in Springboot

WBOY
Release: 2023-05-11 21:52:13
forward
1601 people have browsed it

The reason why com.mysql.cj.jdbc.Driver became popular in yml files

I built a framework a few days ago, and a strange problem occurred. When configuring the mysql file, com.mysql.cj .jdbc.Driver has been popular. I thought the version was too low, so I upgraded to a higher version, but it was still popular. Finally, I checked online for a long time. The online method said that the version was too low, but I still The dependency package I used before was not working:

<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.15</version>
</dependency>
Copy after login

Finally I just removed the version number,

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
Copy after login

driver-class-name: com.mysql.cj.jdbc.Driver code exploded Red's solution

When building and running the springboot project, an error will be reported when adding the database driver.

How to solve the problem of com.mysql.cj.jdbc.Driver becoming popular in yml file in Springboot

Before that, you need to add mysql dependency in pom.xml. In the process of seeking solutions to the problem many times, I found a key statement, which is:

I added the version number in the mysql dependency, and this problem is probably caused by inconsistent version numbers, which resulted in this red topic:

How to solve the problem of com.mysql.cj.jdbc.Driver becoming popular in yml file in Springboot

At this point, the solution to this problem is obvious.

1. Either comment out the mysql dependency in pom.xml

        <!-- 数据库Mysql -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <!--<version>5.7.17</version>-->
        </dependency>
Copy after login
logging:
  path: ./log/
spring:
  datasource:
    url: jdbc:mysql://localhost:3306/xzs?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2b8
    username: root
    password: root
    driver-class-name: com.mysql.cj.jdbc.Driver
Copy after login

2. Or the current MySQL version on the computer is too low, reinstall a MySQL version that is more suitable for the development environment.

The above is the detailed content of How to solve the problem of com.mysql.cj.jdbc.Driver becoming popular in yml file in Springboot. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!