将spring引导从2.1.9升级到2.2.0,现在启动时出现异常
我将SpringBoot从2.1.9升级到2.2.0,现在在启动应用程序时遇到了一些异常 java:openjdk11 spring boot:v2.2.0.0版本 我尝试从下面的位置删除jar,并进行了mvn清理安装,但仍然没有成功 .m2/repository/org/springframework/boot/spring-boot-exactor/2.2.0.RELEASE/spring-boot-exactor-2.2.0.RELEASE.jar 错误:将spring引导从2.1.9升级到2.2.0,现在启动时出现异常,spring,spring-boot,spring-boot-actuator,Spring,Spring Boot,Spring Boot Actuator,我将SpringBoot从2.1.9升级到2.2.0,现在在启动应用程序时遇到了一些异常 java:openjdk11 spring boot:v2.2.0.0版本 我尝试从下面的位置删除jar,并进行了mvn清理安装,但仍然没有成功 .m2/repository/org/springframework/boot/spring-boot-exactor/2.2.0.RELEASE/spring-boot-exactor-2.2.0.RELEASE.jar 错误: ***************
***************************
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.cloud.client.discovery.health.DiscoveryCompositeHealthIndicator.<init>(DiscoveryCompositeHealthIndicator.java:41)
The following method did not exist:
org.springframework.boot.actuate.health.CompositeHealthIndicator.<init>(Lorg/springframework/boot/actuate/health/HealthAggregator;)V
The method's class, org.springframework.boot.actuate.health.CompositeHealthIndicator, is available from the following locations:
jar:file:/C:/Users/regosa/.m2/repository/org/springframework/boot/spring-boot-actuator/2.2.0.RELEASE/spring-boot-actuator-2.2.0.RELEASE.jar!/org/springframework/boot/actuate/health/CompositeHealthIndicator.class
It was loaded from the following location:
file:/C:/Users/regosa/.m2/repository/org/springframework/boot/spring-boot-actuator/2.2.0.RELEASE/spring-boot-actuator-2.2.0.RELEASE.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.boot.actuate.health.CompositeHealthIndicator
如何解决此问题?这似乎是一个已知的问题:
如果在Spring引导应用程序中使用Spring云依赖项,请确保在类路径上有正确的Spring云版本!只有Spring Cloud的“Hoxton”(发布序列目前支持Spring Boot 2.2。这很奇怪。
Spring插件核心
版本应该是2.0.0
,而不是1.2.0
。让我们升级它:
<!-- https://mvnrepository.com/artifact/org.springframework.plugin/spring-plugin-core -->
<dependency>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
org.springframework.plugin
spring插件核心
2.0.0.1版本
实际上,springfox与SpringBoot2.2.0不兼容。springfox似乎已经死了
相反,您可以使用:SpringDoc OpenApi简而言之,问题是由于spring cloud和spring boot版本不兼容,spring boot 2.2.X需要Hoxton release train而不是Greenwich。有关更多信息,请参阅下文 此问题是由于spring-cloud.version不兼容造成的。根据spring-cloud documentation link(),以下是spring引导兼容性: 释放列车弹簧靴兼容性
Release Train Boot Version
Hoxton 2.2.x
Greenwich 2.1.x
因此,如果您要将spring boot更新为2.2.x,那么也要更新为spring cloud的Hoxton发布系列,即Hoxton.RC1()
注:根据2019年11月18日到期的spring cloud里程碑页面Hoxton.RELEASE()更新您的springfox swagger版本。我已经升级了springfox 2.9.2,使用boot 2.2.2运行
SpringFox需要1.2.0版,但Spring Boot 2.2.2本身并没有做到这一点。因此,您在类路径中获得了Spring-plugin-core-1.2.0.RELEASE。然后它会很好地工作。在添加更新的插件核心依赖项后,我也面临同样的问题。现在问题已经解决
<dependency>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
org.springframework.plugin
spring插件核心
2.0.0.1版本
如果spring-plugin-core-1.2.0.RELEASE在您的项目中不起作用,那么另一种方法是将springfox swagger与3.0.0-SNAPSHOT版本一起使用。对于此版本,它有不同的存储库。
存储库url:
它将使用@EnableSwagger2WebMvc注释而不是@EnableSwagger2。2.2.4.RELEASE
<springBootVersion>2.2.4.RELEASE</springBootVersion>
支持的云版本。Hoxton.M2
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Hoxton.M2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
...
</dependencies>
org.springframework.cloud
spring云依赖关系
Hoxton.M2
聚甲醛
进口
org.springframework.cloud
SpringCloudStarter配置
org.springframework.cloud
spring cloud starter netflix eureka客户端
...
如前所述,spring插件核心
依赖项是用错误的1.2.0.RELEASE
版本解决的。为了强制使用正确的2.0.0.RELEASE
,您必须排除错误的可传递依赖项并指定正确的依赖项,或者锁定(!)您的pom.xml
中的依赖项版本。这是在
块中完成的,而不是在
块中完成的。Springfox 3.0.0示例:
<spring-plugin-core.version>2.0.0.RELEASE</spring-plugin-core.version>
<springfox.version>3.0.0</springfox.version>
...
<dependencyManagement>
<dependencies>
<!-- API Documentation -->
<!-- Fix wrong resolved `spring-plugin-core` dependency version for springfox -->
<dependency>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
<version>${spring-plugin-core.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>${springfox.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- API Documentation -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
</dependency>
</dependencies>
2.0.0.0版本
3.0.0
...
org.springframework.plugin
spring插件核心
${spring plugin core.version}
伊奥·斯普林福克斯
springfox启动程序
${springfox.version}
伊奥·斯普林福克斯
springfox启动程序
我将Springfox Swagger 2升级到了3.0.0版本,将spring插件代码升级到了2.0.0.RELEASE版本。这对我很有用。
Spring启动版本-2.3.9.0版本
<dependency>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
<version>2.0.0.RELEASE</version>
</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>3.0.0</version>
</dependency>
org.springframework.plugin
spring插件核心
2.0.0.1版本
伊奥·斯普林福克斯
springfox-Swagger 2
3.0.0
伊奥·斯普林福克斯
springfox招摇过市用户界面
3.0.0
请发布您的pom。xml@EugenCovaci附加的pom.xl请将Greenwich.M1
替换为Greenwich.RELEASE
,看看错误是否消失。最新版本是Greenwich.SR3
,您也可以尝试一下。@EugenCovaci谢谢。现在我得到了另一个说明spring插件核心jar中缺少的方法。.我更新了上面的问题。我现在必须更新哪个插件…?谢谢,现在我遇到了另一个例外。我在上面的问题中更新了它是一个错误。我需要更新任何库吗?确认Greenwich.SR3
不适用于Spring Boot 2.2.0
您需要添加maven{url'https://repo.spring.io/milestone' }
并在Hoxton.RC1
上替换格林威治,但仍然无法从spring插件核心库中获得其他异常(未找到任何方法)。我已更新了上面的错误消息question@JoysonRego运行mvn dependency:tree
并将结果粘贴到错误下方。这是dependency tree链接@JoysonRego,我认为你无法让它工作,除非你放弃springfox
依赖项。他们使用的是较旧版本的spring插件核心
@JoysonRego不是真的。是否还有其他库可用。而不是招摇过市?@JoysonRego Spring REST Docs很棒,但采用了另一种方法。@JoysonRego是的,这里是:ref:这对我有效。我使用的是Greenwich.RELEASE with Spring Boot 2.2.4,当我开始使用Spring Boot启动器执行器时,它开始出现问题。与问题中提到的错误日志相同。已更新为Hoxton.SR1,并且已成功启动。
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Hoxton.M2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
...
</dependencies>
<spring-plugin-core.version>2.0.0.RELEASE</spring-plugin-core.version>
<springfox.version>3.0.0</springfox.version>
...
<dependencyManagement>
<dependencies>
<!-- API Documentation -->
<!-- Fix wrong resolved `spring-plugin-core` dependency version for springfox -->
<dependency>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
<version>${spring-plugin-core.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>${springfox.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- API Documentation -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
</dependency>
</dependencies>
<dependency>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
<version>2.0.0.RELEASE</version>
</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>3.0.0</version>
</dependency>