英文:
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.
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论