An attempt was made to call a method that does not exist. The attempt was made from the following location:

Viewed 7738

I'm working on the Spring boot JPA Gridle project. Current Swagger is running, and an error occurs while DTO is in progress. Modules seem to be colliding with each other.

An error occurs when I install a swagger module, proceed with the swagger, and install the module for DTO. The following modules produce an error:

compile 'org.springframework.boot:spring-boot-starter-hateoas'

And the error is as follows.

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-03-17 01:26:38.657 ERROR 4688 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    springfox.documentation.spring.web.plugins.DocumentationPluginsManager.createContextBuilder(DocumentationPluginsManager.java:152)

The following method did not exist:

    org.springframework.plugin.core.PluginRegistry.getPluginFor(Ljava/lang/Object;Lorg/springframework/plugin/core/Plugin;)Lorg/springframework/plugin/core/Plugin;

The method's class, org.springframework.plugin.core.PluginRegistry, is available from the following locations:

    jar:file:/Users/****/.gradle/caches/modules-2/files-2.1/org.springframework.plugin/spring-plugin-core/2.0.0.RELEASE/95fc8c13037630f4aba9c51141f535becec00fe6/spring-plugin-core-2.0.0.RELEASE.jar!/org/springframework/plugin/core/PluginRegistry.class

It was loaded from the following location:

    file:/Users/****/.gradle/caches/modules-2/files-2.1/org.springframework.plugin/spring-plugin-core/2.0.0.RELEASE/95fc8c13037630f4aba9c51141f535becec00fe6/spring-plugin-core-2.0.0.RELEASE.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.plugin.core.PluginRegistry


Process finished with exit code 1

The things I tried through the search are as well.

compile group: 'org.springframework.plugin', name: 'spring-plugin-core', version: '2.0.0.RELEASE'

compile group: 'io.springfox', name: 'springfox-data-rest', version: '2.9.2'

Neither of them helped me.

Does anyone have the same problem as me?

Is there any other way to solve this problem?

2 Answers

The problem was a conflict between Swagger and Hateoas modules. A number of search results have found a solution.

The solution was to add a new module and register Bean for it.

compile group: 'org.springframework.plugin', name: 'spring-plugin-core', version: '1.2.0.RELEASE'

SwaggerConfig.java

public class SwaggerConfig {

    @Bean
    public LinkDiscoverers discoverers() {
        List<LinkDiscoverer> plugins = new ArrayList<>();
        plugins.add(new CollectionJsonLinkDiscoverer());
        return new LinkDiscoverers(SimplePluginRegistry.create(plugins));
    }

}

For me the problem was a conflict between JPA and Hateoas dependencies.

The solution for me was to remove the JPA dependency since I was interested in using the Hateoas module instead.

Changed this:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.hateoas</groupId>
        <artifactId>spring-hateoas</artifactId>
    </dependency>

To this:

    <dependency>
        <groupId>org.springframework.hateoas</groupId>
        <artifactId>spring-hateoas</artifactId>
    </dependency>
Related