Inspectopedia Help

Incorrect XML Spring bean autowiring

Reports incorrect autowiring of Spring beans configured in XML application contexts.

Example:

public interface FooInterface {...} @Component public class FooBean implements FooInterface {...} @Component public class OtherBean implements FooInterface {...} @Component public class MyComponent { public void setFooInterface(FooInterface foo) {...} }
<beans> <bean class="beans.OtherBean" id="otherBean"/> <bean class="beans.FooBean" id="fooBean"/> <bean autowire="byType" class="beans.MyComponent" id="foo"/> <!-- reports "Could not autowire. There is more than one bean of 'FooInterface' type. --> <!-- Beans: otherBean,fooBean. Properties: 'fooInterface' " --> </beans>

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Spring, 233.SNAPSHOT

Last modified: 13 July 2023