Skip to content

Dependency injection through constructor in 6.1 is not working as expected #32080

@aginga

Description

@aginga

Hi,

The change to the dependency injection though constructor in 6.1 has a really big impact on our apps, and I would really like to know if it can be fixed please.

Sorry, I'm reopening this because my previous ticket was closed. I tried adding parameters=true to the maven compiler plugin as you suggested on the previous ticket, but it made no difference.

Here is a simple example that illustrates the change.

public class Class1 {

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

}

In applicationContext.xml

-- This configuration using named args doesn't work anymore in Spring 6.1, it was working in Spring 6.0 and previous versions. Value 3 is injected as arg1, 2 to arg 2 and 1 to arg 3 in this case




--In spring 6.1 the order of arguments must match the order of the arguments in the class, so the configuration of the bean must look like this below, even though the argument names are specified. We have many beans we would have to manually review and update the order of the args

Thanks,
Alina

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions