Consider defining a bean of type Autowired(required=true) caused by irregular definition of spring 5.1.x class name

When the project was changed to Micro Services, a higher version of spring 5.1.10 was used.

So one class is wrong

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-01-10 10:46:08.665 [main] ERROR org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter - 



Field organizationEsHelper in required a bean of type '' that could not be found.

The injection point has the following annotations:
	- @org.springframework.beans.factory.annotation.Autowired(required=true)


Consider defining a bean of type '' in your configuration.

So I'm going to use Instead of injecting the constructor, the same error is reported.

So at this point you need debug.

BUG View spring Execution Code

    private SpringUtils springUtils;

 @Autowired(required = false)
    private ElasticsearchRestClient client;

    public void initMethod(){



After a bean is initialized, springUtils is used to load the beans. Because springUtils is all about getting the beans from the map bean cache if they exist, or if they don't exist

Then initialize.

Then you can interrupt the point BUG to check in.Then I found that client is a null bean. No wonder it made a mistake.

Continue debug to check in.It is found that within the map allBeanNamesByType, the Beaname corresponding to the class ElasticsearchRestClient has no content.

Even if it's gone:

 @Autowired(required = false)
    private ElasticsearchRestClient client;

Through the debug process, it is found that there are no beaname list s in beanDefinitionNames and manualSingletonNames

The bean name ElasticsearchRestClient exists because if the beans are loaded here, they must be acquired through the bean name and loaded into the initialization bean class.


Why does the class ElasticsearchRestClient not have a bean name?


The way the bean name is defined above.And this usage of this class is fine with old projects.

I also noticed that IDEA prompted me to modify the name of this class, ElasticsearchRestClient. Could it be that the bean name does not conform to the hump rules?

Instead, Elastic SearchRestClient does not have this problem.

So I think this is a high version bug.And I find that some of the code for the spring 5.1.x scan class initialization bean s seems to have been rewritten in the kotlin language.

I won't go into it.(

This is my issue:

Tags: Programming Spring github

Posted on Thu, 09 Jan 2020 19:58:30 -0800 by dvwhi