<spring-expected at least 1 matching bean> missing bean definition

1. 问题描述
...
Error creating bean with name 'A': Injection of resource fields failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [IA] is defined: Unsatisfied dependency of type [interface IA]: expected at least 1 matching bean
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessAfterInstantiation(CommonAnnotationBeanPostProcessor.java:292)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959)

There is no problem with the deployment of the local environment and the test environment. When sending it to the online pre-production environment, an error is reported. The exception is because the bean definition is not found. However, since this is only the case in the pre-production environment, there is no doubt about the bean definition. I have manipulated some things that spring depends on, so I only think that it may be a dependency problem of spring. The cause was not found for 2 hours. Later, my colleagues reminded whether it was a problem with the configuration file, and whether there was a configuration file that was different online. Suddenly I remembered that the spring configuration of different computer rooms on the line is different. . . It dawned on me. . .

2. Problem solving
Because the current code is only adapted to the configuration of computer room A, if you want to pre-release in computer room B, you need to modify the configuration file. In this way, it is indeed the same as the reason for the abnormal reflection, that is, there is no bean configuration. Take it for granted that experience hurts.

For more such questions, please refer to: http://blog.csdn.net/free4294/article/details/38706569

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326832840&siteId=291194637