Inspectopedia Help

Unnecessary autowired dependency in XML application context

Reports autowire attributes in <bean> elements and suggests to explicitly inject bean properties if possible.

Example:

public class MyComponent { public void setOtherBean(OtherBean bean){...} }
<beans> <bean class="beans.OtherBean" id="bar"/> <bean autowire="byType" class="beans.MyComponent"/> <!-- "Unnecessary autowired dependency" --> <!-- suggests "Make autowired dependency explicit" --> </beans>

After applying the quick-fix:

<beans> <bean class="beans.OtherBean" id="bar"/> <bean class="beans.MyComponent" id="foo"> <property name="otherBean" ref="otherBean"/> </bean> </beans>

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Spring, 233.SNAPSHOT

Last modified: 13 July 2023