Muhammed Ozdogan
Muhammed Ozdogan

Reputation: 5877

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

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?

Upvotes: 19

Views: 32701

Answers (5)

Bawantha
Bawantha

Reputation: 4038

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>

Upvotes: 6

Amit Chaudhary
Amit Chaudhary

Reputation: 141

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>

Upvotes: 4

xiaozhiliaoo
xiaozhiliaoo

Reputation: 451

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

Upvotes: 9

Neeraj Sharma
Neeraj Sharma

Reputation: 473

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.

Upvotes: 2

JM Yang
JM Yang

Reputation: 1208

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.

Upvotes: 19

Related Questions