Skip to content

Regression in name-based dependency bean resolution with Groovy #36463

Closed as not planned

Description

@Vampire

I tried to port our Spring 6 tests in Spock to Spring 7 at spockframework/spock#2262.

But I have one problem that seems to be a regression in dependency resolution.

The test https://github.com/spockframework/spock/blob/3c7dfc18581d1f6343f867aea854fd2f3358c0cb/spock-spring/src/test/groovy/org/spockframework/spring/mock/ComplexUsageSpec.groovy runs like that for all of the tested Spring versions. It runs fine in the tested versions, but fails in Spring 7 with

März 14, 2026 2:47:49 AM org.springframework.context.support.GenericApplicationContext refresh
WARNUNG: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'service1WithAlias' defined in org.spockframework.spring.mock.ComplexConfig: Unsatisfied dependency expressed through method 'service1WithAlias' parameter 0: No qualifying bean of type 'org.spockframework.spring.Service2' available: expected single matching bean but found 4: org.spockframework.spring.Service2#0,org.spockframework.spring.Service2#1,org.spockframework.spring.Service2#2,aName

https://ge.spockframework.org/s/td3jw4ipnpsoc/tests/task/:spock-spring:spring7Test/details/org.spockframework.spring.mock.ComplexUsageSpec/context%20loads%20successfully?top-execution=1

When it tries to wire the aService2 dependency for the service1WithAlias bean, previosus versions resolved to the one bean that does not have a qualifier alias or name, i. e. the aService2 bean defined at the top.

Now with Spring 7 it finds all 4 of the Service2 beans defined at the top and complains that it does not know which one to use.

Activity

  1. Vampire commented on Mar 14, 2026

    @Vampire
    Author

    Actually, the same problem is with service1WithAnnotationName and service1WithAdditionalAlias.
    Only if I comment out all three and their assertions, the test runs through.
    So even selection by name does not work as before.

  2. self-assigned this
    on Mar 20, 2026
  3. added
    in: coreIssues in core modules (aop, beans, core, context, expression)
    on Mar 20, 2026
  4. jhoeller commented on Mar 20, 2026

    @jhoeller
    Contributor

    This looks like parameter names are not resolvable. Has that Groovy code effectively been compiled in a -parameters compatible way? Otherwise, this could be a consequence of #29559 where we removed debug symbol introspection in favor of -parameters. Note that we effectively removed debug symbol introspection in 6.1 already, so this should not be 7.0 specific.

  5. changed the title [-]Regression in dependency bean resolution[/-] [+]Regression in name-based dependency bean resolution with Groovy[/+] on Mar 20, 2026
  6. Vampire commented on Mar 21, 2026

    @Vampire
    Author

    Oh, yeah, also for Groovy you have to explicitly enable that metadata generation.
    The Spring 6 tests seem to run against 6.0.0 so were not affected.
    Sorry for the noise and thanks for the help.

  7. added
    status: invalidAn issue that we don't feel is valid
    and removed on Mar 21, 2026
  8. jhoeller commented on Mar 21, 2026

    @jhoeller
    Contributor

    No worries! Good to hear that -parameters solves it for Groovy as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: invalidAn issue that we don't feel is valid

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions