Skip to content

Spring includes incorrect values in @Autowired List #29987

Closed as not planned
Closed as not planned

Description

@armogur

In SpringBoot 3.0.2 I created a bean (list of strings: List<String> variable;), but when I use it, the dependency injection inserts wrong values.

Code example: https://github.com/armogur/collection-demo

Run the code and observe the output, the line starts with two should have the same values that starts with goodWithQualifier.

Workaround:

  1. Remove the type parameter at insertion point(s) like this:
@Autowired
List two;
  1. Add qualifier, for example:
@Autowired
@Qualifier("two")
List<String> goodWithQualifier;

Activity

  1. added
    status: waiting-for-triage
    on Feb 16, 2023
  2. self-assigned this
    on Feb 24, 2023
  3. added
    status: duplicate
    in: core
    and removed
    status: waiting-for-triage
    on Feb 24, 2023
  4. sbrannen commented on Feb 24, 2023

    @sbrannen
    Member

    Hi @armogur,

    Congratulations on opening your first issue for the Spring Framework! 👍

    This is effectively a duplicate of #30022 and #16794.

    In light of that, I am closing this issue.

  5. changed the title [-]SpringBoot returns incorrect values in @Autowired bean[/-] [+]Spring returns incorrect values in `@Autowired` `List`[/+] on Feb 24, 2023
  6. changed the title [-]Spring returns incorrect values in `@Autowired` `List`[/-] [+]Spring includes incorrect values in `@Autowired` `List`[/+] on Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: corestatus: duplicate

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions