Spring 6.1.3 (spring-context, spring-beans)

Hi,

We have a number of applications that use the Spring framework and we use dependency injection a lot. We have many beans.xml files where for injection via constructor the constructor arguments are specified using the "name" attribute.

We're currently working on upgrading from Spring 5 to Spring 6.1.3 and noticed that the order of the named constructor args is important in the beans configuration, it has to match the order of the arguments in the class. This change is forcing us to make a lot of changes to the beans.xml files, and we were wondering if this change was intentional or if this is a bug introduced in 6.1. This was not a problem in 5.Y and even in 6.0, it got introduced in 6.1.

Please let us know if this change can be reverted in 6.1

Thank you, Alina

Comment From: bclozel

I think this is probably linked to parameter name retention. Please upgrade your build configuration accordingly.

if this is not helping, please create a minimal project reproducing the problem and attach it here as a zip file or a git repository and we'll have a look. Thanks!

Comment From: aginga

I added parameters=true to the maven compiler plugin, but it did not help. We'll create a small sample project next week. Thanks! As a quick example, this is what I mean:

/* public class Class1 { --Constructor public Class1(String arg1, String arg2, String arg3) { //do something with arg 1, 2, 3 } }

In applicationContext.xml

-- This doesn't work anymore in Spring 6.1, but was working in Spring 6.0 and before
<bean id="class1" class="com.Class1">
    <constructor-arg name="arg3" value="3"/>
    <constructor-arg name="arg2" value="2"/>
    <constructor-arg name="arg1" value="1"/>
</bean>

--For spring 6.1 you must have now, order of arguments must match the order of the arguments in the class
<bean id="class1" class="com.Class1">
    <constructor-arg name="arg1" value="1"/>
    <constructor-arg name="arg2" value="2"/>
    <constructor-arg name="arg3" value="3"/>
</bean>

*/

Comment From: bclozel

Hi Alina, no need to create a new issue to get attention on this. You can provide a minimal application that reproduces the problem as requested previously and we'll have a look.

Comment From: aginga

Okay, we'll put together a small running app today. Thanks!

Comment From: aginga

As I was putting together the sample app I realized the parameters=true on the maven compiler plugin was in fact making a difference and the dependency injection is working as expected. The plugin configuration was overwritten in another pom when we tried previously, that's why we didn't see it working when we first tried. Thank you and sorry for the trouble. Alina

Comment From: bclozel

Thanks for letting us know Alina! Sorry you had to track this down for so long to find out about that override.