Browse Source
This commit uses the bean factory `isAutowiredCandidate` method directly in `BeanOverrideBeanFactoryPostProcessor` to select a single match among multiple candidates when matching by type. The expected consequence, in most cases, is that this will delegate to a `@Qualifier`-aware `QualifierAnnotationAutowireCandidateResolver`. In that sense, bean overriding by-type matching is now potentially taking Qualifier annotations or meta-annotations into account. It also changes the way existing bean definitions are checked in case a bean name has been specified: factory beans are now taken into account when checking the type of an existing definition matches the expected bean override type. Closes gh-32822pull/32874/head
12 changed files with 319 additions and 43 deletions
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
/* |
||||
* Copyright 2002-2024 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.context.bean.override.example; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Inherited; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
import org.springframework.beans.factory.annotation.Qualifier; |
||||
|
||||
@Target({ElementType.FIELD, ElementType.METHOD}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Inherited |
||||
@Qualifier |
||||
public @interface CustomQualifier { |
||||
} |
||||
Loading…
Reference in new issue