我开始研究将 Spring Boot 应用程序从 1.5.x 迁移到 2。
这个应用程序依赖于 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) 

有人经历过吗?
有解决方案吗?

请您参考如下方法:

我在为使用 spring boot 2.0.x 的 spring boot 微服务集成 hystrix 时遇到了类似的问题。
代替

<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 依赖项下正常启动,没有这个问题。


评论关闭
IT干货网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!