Skip to content

Regression in dependency bean resolution #36463

@Vampire

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.

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