'How can I find out what is registering a Spring bean?

I have an application with a complex mix of @Imports and @ComponentScans.

There is a class marked as @Component that I expected not to be added to the application context, but it is, and I want to climb back the scan chain to find out why is that bean registered.

Is there any easy way I can do that e.g. by using Spring Tools 4 Eclipse's plug-in features or maybe programmatically? Googling keywords led to no result.



Solution 1:[1]

Enable the actuator and look at the beans endpoint (/actuator/beans).

The resource property tells you, where this bean might have been included.

bean defining resource

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Martin Theiss