问题现象
问题原因:
在Maven官方文档中Introduction to the Dependency Mechanism有一段话:
- Dependency management - this allows project authors to
- directly specify the versions of artifacts to be used
- when they are encountered in transitive dependencies or
- in dependencies where no version has been specified.
大概意思是:
pom文件中没有指定版本的依赖或是传递的依赖,如果在dependencyManagement中有指定此依赖版本,那就使用dependencyManagement中定义的版本号。
所以springboot默认配置文件中用dependencyManagement帮我们锁定了8.0.21版本的mysql-connector
(查看默认springboot配置文件参考:
在任一pom文件加上这段,然后ctrl鼠标左键点spring-boot-dependencies进去就看到了
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>
简单查询SpringBoot默认插件版本号_springboot插件版本_Building-ui的博客-CSDN博客)
解决办法:
在parent pom文件中锁定mysql-connector版本
参考文献
Maven dependencyManagement中的依赖版本会覆盖传递依赖版本-蒲公英云