In Spring Framework 3.0.x,
<constructor-arg> has an optional
name attribute which allows you to specify constructor parameter values using the name of the parameter, instead of using the index value of the parameter in the list of constructor parameters. The parameter name resolution is performed using Spring's ASM-based
LocalVariableTableParameterNameDiscoverer class.
However, class compilation must be done with the debugging option enabled (that is, using
javac -g or
javac -g:vars). This causes an issue if you use the
<constructor-arg> optional
name attribute with third party classes which have not been compiled with the required debug information.
To solve this issue, use SpringSource Tool Suite (STS) 2.3.2 during testing. This version has the debugging option active by default.
To verify or change this option:
- Right-click the SpringSource Tool Suite, click Properties, then select the Java Compiler set of options.
- In the Classfile Generation section, the Add variable attributes to generated class files (used by the debugger) option controls this functionality.
- Enabling this option adds the required information about the constructor parameter names to the resulting .class file.