mysql-connector-j与mysql-connector-java Maven依赖的差异

huangapple go评论69阅读模式
英文:

mysql-connector-j vs mysql-connector-java maven dependency differences

问题

这两个 Maven 依赖项用于连接到 MySQL 数据库的区别是:

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
</dependency>

<dependency>
    <groupId>com.mysql</groupId>
    <artifactId>mysql-connector-j</artifactId>
</dependency>
英文:

What is difference between these two Maven dependencies for connecting to MySQL DB:

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
</dependency>

and

<dependency>
    <groupId>com.mysql</groupId>
    <artifactId>mysql-connector-j</artifactId>
</dependency>

答案1

得分: 5

MySQL 重命名了连接器:

https://dev.mysql.com/doc/relnotes/connector-j/8.0/en/news-8-0-31.html

你应该使用 **MySQL Connector/J**

---------------------------------------------
如果你正在使用 **Spring-Boot-3.0** 或更高版本,那么你应该使用 **MySQL Connector/J**

*MySQL JDBC 驱动程序的坐标已从 mysql:mysql-connector-java 更改为 com.mysql:mysql-connector-j。如果你正在使用 MySQL JDBC 驱动程序,请在升级到 Spring Boot 3.0 时相应地更新其坐标。*

https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#mysql-jdbc-driver

此外,根据 @Mar-Z 的评论提供的信息:

> 第二个是正确/当前的。第一个已经过时。
> 它将在 Maven 中更新,但仅在有限的时间内。请查看这里:[MySQL Connector/J has new Maven Coordinates][1]
英文:

TL;DR

Use this

<dependency>
    <groupId>com.mysql</groupId>
    <artifactId>mysql-connector-j</artifactId>
</dependency>

Mysql renamed the connector:

https://dev.mysql.com/doc/relnotes/connector-j/8.0/en/news-8-0-31.html

you should use MySQL Connector/J


If you are using the Spring-Boot-3.0 or above then you should use MySQL Connector/J

The coordinates of the MySQL JDBC driver have changed from mysql:mysql-connector-java to com.mysql:mysql-connector-j. If you are using the MySQL JDBC driver, update its coordinates accordingly when upgrading to Spring Boot 3.0.

https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#mysql-jdbc-driver

Also from the comment @Mar-Z provided this information:

> The second one is the correct/current one. The first one is outdated.
> It will be updated on Maven but for a limited time only. Check here: MySQL Connector/J has new Maven Coordinates

huangapple
  • 本文由 发表于 2023年5月22日 18:04:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76305054.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定