I'm using Spring Tool Suite (STS) to manage a large Java Spring project. Is there a function in STS that allows one to find the declaration of a particular bean by its alias?
For example, if I have the following property in a Java class:
@Resource
private WidgetService widgetService;
I know that this property will be auto-wired from a Spring bean with the name "widgetService"
. The bean injected will be an instance of a class that implements the interface WidgetService
. The implementation(s) may not be located in the same package as the interface. I need a way to quickly determine from that property declaration which implementation will be injected.
I tried searching for widgetService
using the Spring Beans Search, but it came up empty. It came up empty because the bean is defined as follows:
<alias alias="widgetService" name="defaultWidgetService" />
<bean id="defaultWidgetService" class="namespace.DefaultWidgetService"/>
There's the answer to my search (DefaultWidgetService
), but it's inside a bean named "defaultWidgetService". Since the bean that is used to autowire the @Resource
is aliased, the Spring Beans Search doesn't work, as it only has options to search by name, class, etc, but not by alias.
I know I can just use a File Search and search for alias="widgetService"
but because of the size of the project searching by text is quite slow. I could also examine the property at debug time and get the class of the injected bean, but that is also cumbersome. Java Search is quick because it is indexed, and Spring Beans Search is quick for the same reason. But I wonder: why I am using STS (which adds extra time to my builds so STS can index the Spring beans) if it won't help me with finding aliased beans?