我正在尝试使用swagger-ui来调整spring data rest模块,我正在使用springfox 2.1.3.RELEASE版本和2.9.2版本的swagger依赖,包括SpringBoot -data-rest,springfox-swagger2,springfox-swagger-ui。
An attempt was made to call the method org.springframework.data.repository.support.Repositories.getRepositoryInformationFor(Ljava/lang/Class;)Lorg/springframework/data/repository/core/RepositoryInformation; but it does not exist. Its class, org.springframework.data.repository.support.Repositories, is available from the following locations:
jar:file:/Users/batuhan.apaydin/.m2/repository/org/springframework/data/spring-data-commons/2.1.5.RELEASE/spring-data-commons-2.1.5.RELEASE.jar!/org/springframework/data/repository/support/Repositories.class
It was loaded from the following location:
file:/Users/batuhan.apaydin/.m2/repository/org/springframework/data/spring-data-commons/2.1.5.RELEASE/spring-data-commons-2.1.5.RELEASE.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.data.repository.support.Repositories我还试着添加
@Import({springfox.documentation.spring.data.rest.configuration.SpringDataRestConfiguration.class})但是什么都不能解决。
有人知道为什么我会得到这个错误吗?
发布于 2019-07-26 03:16:09
我也遇到了同样的问题,并找到了以下解决方案:
使用Swagger 3.0.0的快照版本
<dependencies>
...
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-data-rest</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
...
</dependencies>
<repositories>
<repository>
<id>JFrog</id>
<name>JFrog Snapshot Repository</name>
<url>http://oss.jfrog.org/artifactory/oss-snapshot-local/</url>
</repository>
</repositories>然后使用@EnableSwagger2WebMvc代替@EnableSwagger2:
@SpringBootApplication
@EnableSwagger2WebMvc
@Import(SpringDataRestConfiguration.class)
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
}正如这里提到的:https://github.com/springfox/springfox/issues/2345#issuecomment-493437424
https://stackoverflow.com/questions/55285164
复制相似问题