gpt4 book ai didi

java - 启动 Spring Cloud Hystrix 仪表板示例时出现问题

转载 作者:行者123 更新时间:2023-12-01 22:39:03 25 4
gpt4 key购买 nike

尝试启动 Hystrix 仪表板并在启动时收到错误。以下是通过 github 提供的示例作为基础。确实没有对代码进行任何更改。只是想启动。

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Configuration
@ComponentScan
@EnableAutoConfiguration
@EnableHystrixDashboard
public class HystrixDashboardApplication {

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

}

@Controller
class HystrixDashboardController {

@RequestMapping("/")
public String home() {
return "forward:/hystrix/index.html";
}

}

下面是报告的错误:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name      'restTemplate' defined in class path resource [org/springframework/cloud/netflix/ribbon/RibbonAutoConfiguration.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframework.cloud.netflix.ribbon.RibbonInterceptor]: : Error creating bean with name 'ribbonInterceptor' defined in class path resource [org/springframework/cloud/netflix/ribbon/RibbonAutoConfiguration.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframework.cloud.client.loadbalancer.LoadBalancerClient]: : Error creating bean with name 'loadBalancerClient': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.cloud.netflix.ribbon.SpringClientFactory org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.clientFactory; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.cloud.netflix.ribbon.SpringClientFactory] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loadBalancerClient': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.cloud.netflix.ribbon.SpringClientFactory org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.clientFactory; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.cloud.netflix.ribbon.SpringClientFactory] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ribbonInterceptor' defined in class path resource [org/springframework/cloud/netflix/ribbon/RibbonAutoConfiguration.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframework.cloud.client.loadbalancer.LoadBalancerClient]: : Error creating bean with name 'loadBalancerClient': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.cloud.netflix.ribbon.SpringClientFactory org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.clientFactory; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.cloud.netflix.ribbon.SpringClientFactory] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loadBalancerClient': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.cloud.netflix.ribbon.SpringClientFactory org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.clientFactory; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.cloud.netflix.ribbon.SpringClientFactory] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

我已经尝试了 spring-cloud-starters 1.0.0.BUILD-SNAPSHOT 和 1.0.0.M1。

最佳答案

目前的解决方法是添加@EnableEurekaClient

我在这里重现并解决了这个问题:https://github.com/spencergibb/communityanswers/tree/so26450251

我已经筹集了issue #35

关于java - 启动 Spring Cloud Hystrix 仪表板示例时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26450251/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com