【问题标题】:application.yml not picked up by hystrixhystrix 未获取 application.yml
【发布时间】:2017-05-29 16:24:38
【问题描述】:

我想将方法​​注释中的以下配置移动到属性文件中

@HystrixCommand(commandProperties = {
            @HystrixProperty(name = "circuitBreaker.sleepWindowInMilliseconds", value = "10000"),
            @HystrixProperty(name = "metrics.rollingStats.timeInMilliseconds", value = "10000"),
            @HystrixProperty(name = "circuitBreaker.requestVolumeThreshold", value = "5"),
            @HystrixProperty(name = "circuitBreaker.errorThresholdPercentage", value = "100")   
    },
            fallbackMethod = "fallbackCall")

我已将 application.yml 文件放在 src/main/resources 下

hystrix:
  command.:
    getResult:
      circuitBreaker:
        sleepWindowInMilliseconds: 10000
        errorThresholdPercentage: 100
        requestVolumeThreshold: 5
      metrics:
        rollingStats:
          timeInMilliseconds: 10000

我没有使用弹簧靴。 Hystrix 没有获取此文件。

是否需要进行任何配置才能将 application.yml 传递给 hystrix 配置?

【问题讨论】:

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


    【解决方案1】:

    创建为 config.properties 并且它有效。 这是由archaius默认查找的

    hystrix.command.getResult.metrics.rollingStats.timeInMilliseconds=10000
    hystrix.command.getResult.circuitBreaker.requestVolumeThreshold=5
    hystrix.command.getResult.circuitBreaker.errorThresholdPercentage=100
    hystrix.command.getResult.circuitBreaker.sleepWindowInMilliseconds=10000
    

    【讨论】:

    • 有一座桥,它确实有效。你的依赖肯定有问题,你是怎么引入hystrix的?
    【解决方案2】:

    我遇到了类似的问题,我们在项目中使用 Spring boot 和 Spring Cloud 依赖项。添加以下依赖项已解决问题,

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
        <version>${version-as-per-your-project}</version>
    </dependency>
    

    我们最初使用以下导致问题的依赖项进行测试,

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

    【讨论】:

      猜你喜欢
      • 2019-06-27
      • 1970-01-01
      • 2021-01-31
      • 2016-02-26
      • 2017-05-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-19
      • 1970-01-01
      相关资源
      最近更新 更多