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>

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Spring, 233.SNAPSHOT

Last modified: 13 July 2023