【问题标题】:Spring Boot with Hystrix带有 Hystrix 的 Spring Boot
【发布时间】:2019-09-10 08:30:45
【问题描述】:

我在我的大学项目中使用带有 Hystrix 的 Spring Boot。 我遇到的问题是,当我将 Netflix Hystrix 依赖项添加到 pom.xml 文件并运行程序时,它会抛出一个名为 AbstractMethodError 的错误:null,但没有 Netflix Hystrix 依赖项的程序运行时没有任何错误。我该如何解决这个问题?

这些是我的依赖项

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

【问题讨论】:

  • 你能发布堆栈跟踪吗?
  • java.lang.AbstractMethodError: null at org.springframework.core.OrderComparator.findOrder(OrderComparator.java:142) ~[spring-core-5.0.9.RELEASE.jar:5.0.9。 RELEASE] 在 org.springframework.core.annotation.AnnotationAwareOrderComparator.findOrder(AnnotationAwareOrderComparator.java:65) ~[spring-core-5.0.9.RELEASE.jar:5.0.9.RELEASE] 在 org.springframework.core.OrderComparator。 getOrder(OrderComparator.java:125) ~[spring-core-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.core.OrderComparator.getOrder(OrderComparator.java:113) ~[spring-core -5.0.9.RELEASE.jar:5.0.9.RELEASE] 在

标签: spring-boot spring-cloud spring-cloud-netflix hystrix


【解决方案1】:

这是由于依赖项不匹配造成的。应用程序正在尝试调用一个抽象方法,但它没有找到该方法。所以,它抛出了 null 异常。

如下使用两个依赖 netflix-hystrix-dashboard 和 hystrix。

 <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
</dependency>

【讨论】:

  • 如果使用这两个依赖仍然有错误,请检查类路径依赖的版本。
  • 将 Spring Boot 版本更改为 2.1.4 后这对我有用
猜你喜欢
  • 2017-05-04
  • 2017-10-10
  • 2020-11-30
  • 2019-05-08
  • 2017-02-06
  • 2015-04-06
  • 2018-10-25
  • 2018-07-14
  • 2017-03-06
相关资源
最近更新 更多