1

应用程序.java

@Configuration
@ComponentScan
@EnableAutoConfiguration 
@EnableZuulProxy
public class ZuulServer {

     public static void main(String[] args) {
         SpringApplication.run(ZuulServer.class, args);
     }
 }

应用程序.yml

  eureka:
    client:
      enabled: true
        serviceUrl:
           defaultZone: http://localhost:8761/v2/

  zuul:
    proxy:
       route:
         service1: /myservice1
         service2: /myservice2

示例调用:

http://localhost:8080/proxy/myservice1/users
http://localhost:8080/proxy/myservice2/auctionlots/today

预装饰过滤器在路由期间工作,出现以下错误(使用 1.0.0.M2):

Caused by: java.lang.NoSuchMethodError: com.netflix.hystrix.HystrixExecutableBase$ObservableCommand.toBlocking()Lrx/observables/BlockingObservable;
        at com.netflix.hystrix.HystrixExecutableBase.queue(HystrixExecutableBase.java:342)
        at com.netflix.hystrix.HystrixObservableCommand.queue(HystrixObservableCommand.java:50)
        at com.netflix.hystrix.HystrixExecutableBase.execute(HystrixExecutableBase.java:296)
        at com.netflix.hystrix.HystrixObservableCommand.execute(HystrixObservableCommand.java:50)
        at com.netflix.hystrix.HystrixCommand.execute(HystrixCommand.java:485)
        at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.forward(RibbonRoutingFilter.java:162)
        at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.run(RibbonRoutingFilter.java:86)
        at com.netflix.zuul.ZuulFilter.runFilter(ZuulFilter.java:112)
        at com.netflix.zuul.FilterProcessor.processZuulFilter(FilterProcessor.java:197)
        ... 41 common frames omitted
4

1 回答 1

2

@vladsfl 我的示例应用程序与您提供的代码有效。该特定错误来自 rxjava 的不兼容版本(可能是旧版本)。我的示例中的版本(以及适用于 hystrix 的版本)是com.netflix.rxjava:rxjava-core:jar:0.20.6. 你能提供你的配置吗?你有什么版本的 rxjava?

于 2014-11-20T17:53:08.573 回答