NoSuchMethodError: org.springframework.plugin.core.PluginRegistry.getPluginOrDefaultFor [英] NoSuchMethodError: org.springframework.plugin.core.PluginRegistry.getPluginOrDefaultFor

查看:31
本文介绍了NoSuchMethodError: org.springframework.plugin.core.PluginRegistry.getPluginOrDefaultFor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一切都很好,即使使用 Swagger 但是在新构建项目之后突然无法编译抛出

Everything was fine, even with Swagger however suddenly after new build project won't compile throwing

Caused by: org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NoSuchMethodError: org.springframework.plugin.core.PluginRegistry.getPluginOrDefaultFor(Ljava/lang/Object;Lorg/springframework/plugin/core/Plugin;)Lorg/springframework/plugin/core/Plugin;

我已经尝试过此链接的解决方案:https://github.com/springfox/springfox/issues/2932但是编译错误仍然存​​在.

I have tried solution from this link: https://github.com/springfox/springfox/issues/2932 however compilation error still persist.

我正在附加 pom.xml 文件:

I am attaching pom.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.0.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.geborskimateusz.microservices.composite.movie</groupId>
    <artifactId>movie-composite-service</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <name>movie-composite-service</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
        <swagger.version>3.0.0-SNAPSHOT</swagger.version>
    </properties>


    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.projectreactor</groupId>
            <artifactId>reactor-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.8</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.geborskimateusz</groupId>
            <artifactId>api</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.geborskimateusz</groupId>
            <artifactId>util</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.1.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>${swagger.version}</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-spring-webflux</artifactId>
            <version>${swagger.version}</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>${swagger.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-stream-kafka</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-stream-test-support</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Greenwich.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

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


    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

任何想法,这与swagger版本有关吗?

Any ideas, is this related to swagger version?

推荐答案

当使用给定的方法签名编译了一段代码,但在运行时发现另一个代码时,会发生此错误.

This error happens when a piece of code has been compiled with a given method signature, but at runtime, another is found.

这通常发生在编译时使用的依赖项版本与运行时实际提供给程序的依赖项版本之间存在差异时.

This usually happens when there's a difference between the version of a dependency used at compile time, and the dependency that is actually provided to the program at runtime.

我们刚刚和一位同事也遇到了这个错误,我们通过简单地将 Spring Boot 版本更改为 2.2.2 来修复它.

We just had this error as well with a colleague, and we fixed it by simply changing the spring boot version to 2.2.2.

不确定到底发生了什么,但鉴于版本是快照,一个疯狂的猜测是 springfox 的最后一个工作版本(为你和我们工作)是用低于 2.2.2 的 Spring 引导版本编译的.该启动版本具有不同的 getPluginOrDefaultFor 方法签名(或者可能根本不存在该方法).

Not sure what exactly happened, but given the version is a SNAPSHOT, a wild guess would be that the last working version of springfox (working for you and us) was compiled with a Spring boot version inferior to 2.2.2. That boot version had a different method signature for getPluginOrDefaultFor (or possibly the method didn't exist at all).

你的程序看不出有什么不同,因为swagger lib的API没有改变,所以似乎没有任何变化,突然出现错误.但是实际 swagger lib 的底层实现依赖于 Spring Boot 2.2.2 中的某些方法,由于 Boot 的版本是 2.1.0,因此在您的设置中找不到该方法,这会在它期望找到的内容与实际找到的内容之间产生冲突

Your program sees no difference, because the swagger lib's API didn't change, so it seems like nothing changed and there's suddenly an error. But the actual swagger lib's underlying implementation relies on some method from Spring Boot 2.2.2, which it doesn't find in your setup since Boot's version is 2.1.0, and this generates a conflict between what it expects to find and what it actually does.

无论如何,只需将 Boot 升级到 2.2.2 即可解决;如果您不需要 webflux 模块,可能会将 spring-fox 降级到 2.9.2-但似乎您这样做了(没有机会尝试,因为在我们的情况下我们确实需要 springfox webflux 依赖项)

Anyway, just upgrading your Boot to 2.2.2 should fix it ; possibly downgrading spring-fox to 2.9.2 if you don't need the webflux module- but it seems you do (didn't get the chance to try, because in our case we do need the springfox webflux dependency)

这篇关于NoSuchMethodError: org.springframework.plugin.core.PluginRegistry.getPluginOrDefaultFor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆