我开始研究将Spring Boot应用程序从1.5.x迁移到2。这个应用程序依赖于hystrix,而hystrix目前还不兼容Spring Boot 2。当我的pom中有以下内容时:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
<version>1.4.4.RELEASE</version>
</dependency>启动应用程序时出现以下错误:
java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Object;)V
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:125)有没有人有过同样的经历?有解决方案吗?
发布于 2019-05-08 22:15:52
我在为我的spring boot微服务集成hystrix时也遇到过类似的问题,该微服务使用spring boot 2.0.x。而不是
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
<version>${spring-hystrix.version}</version>
</dependency>我已经搬到
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
<version>${spring-hystrix.version}</version>
</dependency>Spring boot 2.0.x应用程序在spring-cloud-starter-netflix-hystrix依赖中启动得很好,没有这个问题。
发布于 2018-05-17 18:39:41
经过进一步的研究,我找到了一个解决方案,将以下代码添加到pom文件中:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.RC1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>所有版本的spring-cloud-dependencies似乎都与Spring Boot2.x.x不兼容
发布于 2018-06-25 20:22:58
我在启动Spring Boot2时也遇到了这个问题,因为spring-cloud-starter-hystrix是我在项目中使用的依赖项。然而,我发现spring-cloud-starter-hystrix已经被弃用了。我还发现我在那里使用的feign类已经被移到了spring-cloud-openfeign (https://github.com/spring-cloud/spring-cloud-openfeign)。所以我所做的就是从我的依赖中移除spring-cloud-starter-hystrix,并添加spring-cloud-openfeign。这对我来说非常有效。
基本上我换掉了
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-hystrix', version: '1.4.4.RELEASE'
使用
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign', version: '2.0.0.RELEASE'
Spring Boot 2已经准备好了。希望这能有所帮助。
注:我使用Gradle,如果需要,您可以很容易地找到maven pom依赖等价物。
https://stackoverflow.com/questions/50346613
复制相似问题