The following method did not exist: 'org.springframework.plugin.core.PluginRegistry org.springframework.plugin.core.PluginRegistry.of(java.util.List)'
Asked Answered
V

5

19

pom.xml

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jetty</artifactId>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.12</version>
            <scope>provided</scope>
        </dependency>

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

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
            <version>2.2.5.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>

        <!-- The Bad Boy -->
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-rest-hal-browser</artifactId>
            <version>3.2.5.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.plugin</groupId>
            <artifactId>spring-plugin-core</artifactId>
            <version>1.2.0.RELEASE</version>
        </dependency>
    </dependencies>

With these dependencies I get following error:

    *************************** 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:

        org.springframework.data.rest.core.support.UnwrappingRepositoryInvokerFactory.<init>(UnwrappingRepositoryInvokerFactory.java:57)

    The following method did not exist:

        'org.springframework.plugin.core.PluginRegistry org.springframework.plugin.core.PluginRegistry.of(java.util.List)'

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

        jar:file:/home/md7zn4/.m2/repository/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar!/org/springframework/plugin/core/PluginRegistry.class

    It was loaded from the following location:

        file:/home/md7zn4/.m2/repository/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar


    Action:

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

If I delete Hal Browser Dependency everything works fine:

        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-rest-hal-browser</artifactId>
            <version>3.2.5.RELEASE</version>
        </dependency>

I have tried to update spring-plugin-core to 2.0.0-RELEASE but this time I get the following error:

***************************
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.Plugin org.springframework.plugin.core.PluginRegistry.getPluginFor(java.lang.Object, org.springframework.plugin.core.Plugin)'

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

    jar:file:/home/md7zn4/.m2/repository/org/springframework/plugin/spring-plugin-core/2.0.0.RELEASE/spring-plugin-core-2.0.0.RELEASE.jar!/org/springframework/plugin/core/PluginRegistry.class

Also I check this.

I think there is a conflict on spring-plugin-core How can fix this?

Vladi answered 16/3, 2020 at 16:55 Comment(3)
I too am facing this issue. Did you manage to resolve it ? Thanks for any commentsSquish
I have tried dozens of combination at different versions of spring-hateoas and swagger but it didn't work.Vladi
Thanks , I'm doing a Udemy course and have asked there . If they get back to me I'll post the solution.Squish
B
19

Cause

When this error is displayed:

The following method did not exist:

'org.springframework.plugin.core.PluginRegistry org.springframework.plugin.core.PluginRegistry.of(java.util.List)'

It means spring-plugin-core 1.2.0 is in effect. This is good for springfox-swagger2 v2.9.2, however, some other components can't find PluginRegistry.of(java.util.List) in spring-plugin-core, because it is defined in a later version.

When this error is displayed:

The following method did not exist:

'org.springframework.plugin.core.Plugin org.springframework.plugin.core.PluginRegistry.getPluginFor(java.lang.Object, org.springframework.plugin.core.Plugin)'

It means spring-plugin-core 2.0.0 is in effect. This time, springfox-swagger2 v2.9.2 runs into problem because PluginRegistry.getPluginFor(java.lang.Object, org.springframework.plugin.core.Plugin) is removed from this version.

Solution

You may resolve this issue by using the snapshot version of springfox library. It has been upgraded to use the newer version of spring-plugin-core.

<dependency>
  <groupId>io.springfox</groupId>
  <artifactId>springfox-swagger2</artifactId>
  <version>3.0.0-SNAPSHOT</version>
</dependency>

Please add the repository definition in order to use this snapshot version:

<repositories>
  <repository>
    <id>jcenter-snapshots</id>
    <name>jcenter</name>
    <url>http://oss.jfrog.org/artifactory/oss-snapshot-local/</url>
  </repository>
</repositories>

Please also replace @EnableSwagger2 with @EnableSwagger2WebMvc.

Barge answered 13/5, 2020 at 3:1 Comment(2)
@EnableSwagger2WebMvc is now Deprecated. Couldn't find the reason why.Handmaid
Also, v3+ for springfox is out: no need for the SNAPSHOT anymore. (Sorry, I'm a bit late: couldn't edit my last message.)Handmaid
H
9

Spring Plugins version is low, add this to pom.xml.

<dependency>
        <groupId>org.springframework.plugin</groupId>
        <artifactId>spring-plugin-core</artifactId>
        <version>2.0.0.RELEASE</version>
 </dependency>

you can find similar issue here: https://github.com/springfox/springfox/issues/2968

Holmgren answered 23/8, 2020 at 9:34 Comment(0)
D
6

In my case I just upgrade my swagger version, and it worked.

<dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>3.0.0</version>
</dependency>
Dvinsk answered 18/4, 2021 at 15:40 Comment(0)
S
4

I faced the same problem and this is what worked for me-

1.Use HAL explorer instead of HAL browser

2.Update springfox dependency version

    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-rest-hal-explorer</artifactId>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>3.0.0</version>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>2.9.2</version>
    </dependency>
Stadtholder answered 25/10, 2020 at 4:51 Comment(1)
you are big, bro!Analysand
K
2

either run maven dependency tree command to see that which two jars are included and remove one or an easier way is to delete .m2 folder and re import the dependencies it will fix the issue.

Kinard answered 4/6, 2020 at 22:40 Comment(1)
This is helped me, Cheer!Obreption

© 2022 - 2024 — McMap. All rights reserved.