【发布时间】:2020-01-17 22:19:38
【问题描述】:
我正在尝试将 QueryDSL 用于 Spring Data 谓词解析以及用于我的 Spring Boot 服务的 Swagger API 文档。但是我遇到了一个问题。当我的应用程序启动时,我收到以下错误消息:
java.lang.NoSuchMethodError: 'com.google.common.collect.FluentIterable com.google.common.collect.FluentIterable.concat(java.lang.Iterable, java.lang.Iterable)
An attempt was made to call a method that does not exist. The attempt was made from the following location:
springfox.documentation.schema.DefaultModelDependencyProvider.dependentModels(DefaultModelDependencyProvider.java:79)
The following method did not exist:
'com.google.common.collect.FluentIterable com.google.common.collect.FluentIterable.concat(java.lang.Iterable, java.lang.Iterable)'
The method's class, com.google.common.collect.FluentIterable, is available from the following locations:
jar:file:/my_m2/com/google/guava/guava/18.0/guava-18.0.jar!/com/google/common/collect/FluentIterable.class
Action:
Correct the classpath of your application so that it contains a single, compatible version of com.google.common.collect.FluentIterable
我发现发生这种情况是因为 QueryDSL 依赖于 Guava 18.0 库,但 Springfox / Swagger 依赖于 Guava 20.0 库,所以我最终在我的类路径中使用了两个版本的库,maven 似乎优先考虑18.0 一个。如何解决这种依赖不匹配?有什么方法可以强制 QueryDSL 尝试使用 Guava 20.0(希望它仍然可以运行)?或者有没有其他方法可以解决这个问题?
版本:
Spring Boot 版本:2.1.9.RELEASE
此版本的 Spring Boot 使用 QueryDSL 版本:4.2.1
Springfox Swagger 版本:2.9.2
【问题讨论】:
标签: java spring spring-boot swagger querydsl