eureka 单元测试 Error creating bean with name 'eurekaAutoServiceRegistration': Singleton bean...
单元测试时如果遇到以下报错信息,有两种方式解决org.springframework.beans.factory.BeanCreationNotAllowedException:Error creating bean with name 'eurekaAutoServiceRegistration': Singleton bean...方法一:添加注解在单元测试类中添加如下注解...
·
单元测试时如果遇到以下报错信息,有两种方式解决 org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'eurekaAutoServiceRegistration': Singleton bean...
方法一:添加注解
在单元测试类中添加如下注解(放心不会有地方引用,但是不能删除)
@MockBean
private EurekaAutoServiceRegistration eurekaAutoServiceRegistration;
方法二:实现 BeanFactoryPostProcessor接口
@Component
public class FeignBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
BeanDefinition bd = beanFactory.getBeanDefinition("feignContext");
bd.setDependsOn("eurekaServiceRegistry", "inetUtils");
}
}
更多推荐
已为社区贡献5条内容
所有评论(0)