BeanCreationNotAllowedException: Error creating bean with name 'eurekaAutoServiceRegistration' 以及 Windows 找到端口对应pid

  • 原代码
@EnableDiscoveryClient
@EnableCircuitBreaker
@EnableFeignClients
@SpringBootApplication
public class WebappApplication{
   
    public static void main(String[] args) {
        SpringApplication.run(WebappApplication.class, args);
    }
}
  • 修改后代码
@EnableDiscoveryClient
@EnableCircuitBreaker
@EnableFeignClients
@SpringBootApplication
public class WebappApplication implements BeanFactoryPostProcessor {
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        BeanDefinition bd = beanFactory.getBeanDefinition("feignContext");
        bd.setDependsOn("eurekaServiceRegistry", "inetUtils");
    }

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

posted @ 2018-12-17 10:42  twfb  阅读(3778)  评论(0编辑  收藏  举报