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>

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

SpringXmlAutowiringInspection
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Spring | Spring Core | XML

Availability

By default bundled with

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin

Spring, 241.18072

Last modified: 18 June 2024