If you encounter the following error message during unit testing, there are two ways to resolve it org.springframework.beans.factory.BeanCreationNotAllowedException: 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)
@MockBean
private EurekaAutoServiceRegistration eurekaAutoServiceRegistration;
Method 2: implement the beanfactory postprocessor interface
@Component
public class FeignBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
BeanDefinition bd = beanFactory.getBeanDefinition("feignContext");
bd.setDependsOn("eurekaServiceRegistry", "inetUtils");
}
}
Read More:
- Spring cloud Eureka error creating bean with name
- [Solved] UnsatisfiedDependencyException: Error creating bean with name
- [Solved] Error getting bean using springboot: no qualifying bean of type ‘xxx’ available
- [Solved] Error creating bean with name rController‘: Unsatisfied dependency expressed through field
- [Solved] Springboot Error creating bean with name ‘dataSource’ defined in class path resource
- Error creating bean with name ‘studentMapper‘ defined in file
- [Solved] Error creating bean with name ‘sqlSessionFactory‘ defined in class path resource
- How to Solve Error creating bean with name ‘log’loginController’
- Error creating bean with name ‘captchaController‘: Unsatisfied dependency expressed through field ‘c
- [Solved] Error creating bean with name ‘enableRedisKeyspaceNotificationsInitializer‘ defined in class path
- [Solved] org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘dataSource‘
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘globalTransa
- [Solved] springmvc:Error creating bean with name ‘org.springframework.cache.interceptor.CacheInterceptor
- Eclipse Tomcat Error creating bean with name ‘sqlSessionFactory’ defined in URL…
- When integrating redis with SSM framework, error creating bean with name ‘rediscontentserviceimpl’ defined in file
- Error creating bean with name ‘redistemplate’ defined in class path resource
- [Solved] nacos Startup Error: Error creating bean with name ‘authFilterRegistration‘ defined in class path resource
- AOP Error Cannot resolve reference to bean ‘txPointCut‘ while setting bean property ‘po
- [Solved] Error creating bean with name ‘braveHttpServerHandler‘ defined in class path
- [Solved] Redis Error: Error creating bean with name stringRedisTemplate defined in class path resource