Eureka unit test error creating bean with name ‘Eureka autoservice registration’: Singleton bean

 If you encounter the following error message during unit testing, there are two ways to resolve it
 Error creating bean with name 'eurekaAutoServiceRegistration': Singleton bean...

Method 1: add notes

Add the following annotation to the unit test class (rest assured that there will be no local reference, but it cannot be deleted)

private EurekaAutoServiceRegistration eurekaAutoServiceRegistration;

Method 2: implement the beanfactory postprocessor interface

public class FeignBeanFactoryPostProcessor implements BeanFactoryPostProcessor {

    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        BeanDefinition bd = beanFactory.getBeanDefinition("feignContext");
        bd.setDependsOn("eurekaServiceRegistry", "inetUtils");

Read More: