首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring Data Rest模块2.1.3和Swagger 2.9.2导致问题

Spring Data Rest模块2.1.3和Swagger 2.9.2导致问题
EN

Stack Overflow用户
提问于 2019-03-22 00:32:49
回答 1查看 576关注 0票数 4

我正在尝试使用swagger-ui来调整spring data rest模块,我正在使用springfox 2.1.3.RELEASE版本和2.9.2版本的swagger依赖,包括SpringBoot -data-rest,springfox-swagger2,springfox-swagger-ui。

代码语言:javascript
复制
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

我还试着添加

代码语言:javascript
复制
@Import({springfox.documentation.spring.data.rest.configuration.SpringDataRestConfiguration.class})

但是什么都不能解决。

有人知道为什么我会得到这个错误吗?

EN

回答 1

Stack Overflow用户

发布于 2019-07-26 03:16:09

我也遇到了同样的问题,并找到了以下解决方案:

使用Swagger 3.0.0的快照版本

代码语言:javascript
复制
<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:

代码语言:javascript
复制
@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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55285164

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档