appear org.springframework.beans . factory.BeanCreationException Causes and solutions of abnormal

1 Abnormal description
After checking out the project from SVN and configuring it, start the Tomcat server and report the following error:

2 Abnormal Causes
By observing the abnormal information marked in the figure above, we can know

Org. Springframework. Beans. Factory. BeanCreationException: Error creating bean with the name ‘XXX’

This exception is: Injection bean failed exception.
To put it bluntly, if this exception occurs, the corresponding bean cannot be found! The reasons why bean injection can fail include but are not limited to the following:
The corresponding bean is not annotated; @service stead of dubbo; Select the wrong automatic injection method, etc.
3 Solutions
Now that we know the cause of this exception, we look back at the corresponding Bean declaration and see that the code that injected the Facade is:

@Autowired
ErrorCodeFacade errorCodeFacade;

Well, here’s the mistake! In general, when injecting interfaces at the Service and Biz layer, you can use @Autowiredfor example:

@Autowired
ErrorCodeService errorCodeService;

But, when injected into the Facade layer interface, should use the RemoteServiceFactory. GetService () , such as:

ErrorCodeFacade errorCodeFacade = RemoteServiceFactory.getService(ErrorCodeFacade.class);

That is, the exception is resolved by declaring the ErrorCodeFacade with the code above.


Warm prompt: there are many reasons for this exception, the above only lists the problems I encountered and solutions, I hope to be helpful to you!

Read More: