Mat*_*ski 6 spring swagger spring-boot
一切都很好,即使使用 Swagger,但在新构建项目之后突然无法编译抛出
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;
Run Code Online (Sandbox Code Playgroud)
我已经尝试过这个链接的解决方案:https : //github.com/springfox/springfox/issues/2932 但是编译错误仍然存在。
我附上 pom.xml 文件:
<?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>
Run Code Online (Sandbox Code Playgroud)
任何想法,这与招摇版本有关吗?
Mik*_*ado 10
当使用给定的方法签名编译了一段代码,但在运行时发现了另一个代码时,会发生此错误。
这通常发生在编译时使用的依赖项版本与运行时实际提供给程序的依赖项之间存在差异时。
我们刚刚和一位同事也遇到了这个错误,我们通过简单地将 spring boot 版本更改为 2.2.2 来修复它。
不确定到底发生了什么,但鉴于版本是快照,一个疯狂的猜测是 springfox 的最后一个工作版本(为你和我们工作)是用低于 2.2.2 的 Spring 引导版本编译的。该引导版本具有不同的 getPluginOrDefaultFor 方法签名(或者可能根本不存在该方法)。
您的程序没有任何区别,因为 swagger lib 的 API 没有改变,所以似乎没有任何改变,突然出现错误。但是实际 swagger lib 的底层实现依赖于 Spring Boot 2.2.2 中的某些方法,由于 Boot 的版本是 2.1.0,因此在您的设置中找不到该方法,这会在它期望找到的内容与实际找到的内容之间产生冲突做。
无论如何,只需将您的 Boot 升级到 2.2.2 即可解决;如果您不需要 webflux 模块,可能会将 spring-fox 降级到 2.9.2-但似乎您这样做了(没有机会尝试,因为在我们的情况下,我们确实需要 springfox webflux 依赖项)
| 归档时间: |
|
| 查看次数: |
10865 次 |
| 最近记录: |