Inspectopedia Help

Inconsistent injection value in XML application context

Reports inconsistent tags and attributes on injection points in XML application contexts.

  • <property> and <constructor-arg> must specify a ref, value, or a sub-element

  • <property> and <constructor-arg> cannot contain more than one sub-element

  • <ref> can contain either a bean attribute, a local attribute, or a parent attribute

  • <ref> must specify a bean

  • <idref> can contain either a bean attribute or a local attribute

  • <idref> must specify a bean

  • <map> must specify a key

  • <idref> can contain either a key attribute, a key-ref attribute, or a <key> sub-element

Example:

<beans> <!-- 1. Property is only allowed to contain either "ref" attribute OR "value" attribute OR sub-element --> <bean class="MyClass"> <property name="bean" ref="myBean" value="foo"/> <!-- Property is only allowed to contain either "ref" attribute OR "value" attribute OR sub-element --> </bean> <!-- 2. Property must not contain more than one sub-element --> <bean class="MyFactory"> <property name="bean"> <ref>bean</ref> <!-- Property must not contain more than one sub-element --> <value>foo</value> <!-- Property must not contain more than one sub-element --> </property> </bean> <!-- 3. Map entry must specify a key --> <bean class="MyBean"> <property name="map"> <map> <entry value="foo"/> <!-- Map entry must specify a key --> </map> </property> </bean> </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.

SpringInjectionValueConsistencyInspection
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

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.2, Qodana for JVM 2024.2,

Can be installed with plugin:

Spring, 242.22892

Last modified: 11 September 2024