当你引入依赖 A 时,A 会自动引入它自己的依赖(B、C、D),这叫**传递依赖**。 但有时 B、C、D 的版本和你项目中已有的版本**冲突**,或者你**根本不需要**这些传递依赖。 `` 就是用来 **切断这种自动传递**,手动控制依赖版本。 使用minio时出现报错如下: ```md An attempt was made to call a method that does not exist. The attempt was made from the following location: io.minio.S3Base.(S3Base.java:104) The following method did not exist: ``` 修复maven配置如下: ```xml io.minio minio 8.5.7 com.squareup.okhttp3 okhttp com.squareup.okhttp3 okhttp 4.12.0 ``` Loading... 当你引入依赖 A 时,A 会自动引入它自己的依赖(B、C、D),这叫**传递依赖**。 但有时 B、C、D 的版本和你项目中已有的版本**冲突**,或者你**根本不需要**这些传递依赖。 `<exclusions>` 就是用来 **切断这种自动传递**,手动控制依赖版本。 使用minio时出现报错如下: ```md An attempt was made to call a method that does not exist. The attempt was made from the following location: io.minio.S3Base.<clinit>(S3Base.java:104) The following method did not exist: ``` 修复maven配置如下: ```xml <dependency> <groupId>io.minio</groupId> <artifactId>minio</artifactId> <version>8.5.7</version> <exclusions> <!-- 排除 minio 自带的旧版本 okhttp --> <exclusion> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp</artifactId> </exclusion> </exclusions> </dependency> <!-- 手动指定你需要的版本 --> <dependency> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp</artifactId> <version>4.12.0</version> </dependency> ``` 最后修改:2026 年 05 月 08 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 你的点赞将成为我坚持的动力,之一