4
votes

I'm trying to adapt spring data rest module with swagger-ui , i am using SpringBoot 2.1.3.RELEASE version and 2.9.2 version for swagger dependencies which includes springfox-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

I also tryed to add

@Import({springfox.documentation.spring.data.rest.configuration.SpringDataRestConfiguration.class})

but nothing fixed .

Anybody have an idea why am i getting this error ?

1
Please show your pom.xml- - mle

1 Answers

0
votes

I had the same problem and found the following solution:

Used Snapshot Version of 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>

Then use @EnableSwagger2WebMvc instead of @EnableSwagger2:

@SpringBootApplication
@EnableSwagger2WebMvc
@Import(SpringDataRestConfiguration.class)
public class MyApplication {

    public static void main(String[] args) {
        SpringApplication.run(MyApplication.class, args);
    }

}

As mentioned here: https://github.com/springfox/springfox/issues/2345#issuecomment-493437424