Clarify component scanning of abstract classes with @Lookup methods
Due to changes in gh-19118, classes that contain @Lookup methods are
no longer required to be concrete classes for use with component
scanning; however, the reference documentation still states that such
classes must not be abstract.
This commit therefore removes the outdated reference documentation and
updates the corresponding Javadoc.
See gh-19118
Closes gh-34367
(cherry picked from commit 819a7c86c1
)
This commit is contained in:
parent
5b1a7c7f21
commit
b7a996a64b
|
@ -120,8 +120,6 @@ dynamically generate a subclass that overrides the method.
|
||||||
subclasses cannot be `final`, and the method to be overridden cannot be `final`, either.
|
subclasses cannot be `final`, and the method to be overridden cannot be `final`, either.
|
||||||
* Unit-testing a class that has an `abstract` method requires you to subclass the class
|
* Unit-testing a class that has an `abstract` method requires you to subclass the class
|
||||||
yourself and to supply a stub implementation of the `abstract` method.
|
yourself and to supply a stub implementation of the `abstract` method.
|
||||||
* Concrete methods are also necessary for component scanning, which requires concrete
|
|
||||||
classes to pick up.
|
|
||||||
* A further key limitation is that lookup methods do not work with factory methods and
|
* A further key limitation is that lookup methods do not work with factory methods and
|
||||||
in particular not with `@Bean` methods in configuration classes, since, in that case,
|
in particular not with `@Bean` methods in configuration classes, since, in that case,
|
||||||
the container is not in charge of creating the instance and therefore cannot create
|
the container is not in charge of creating the instance and therefore cannot create
|
||||||
|
@ -293,11 +291,6 @@ Kotlin::
|
||||||
----
|
----
|
||||||
======
|
======
|
||||||
|
|
||||||
Note that you should typically declare such annotated lookup methods with a concrete
|
|
||||||
stub implementation, in order for them to be compatible with Spring's component
|
|
||||||
scanning rules where abstract classes get ignored by default. This limitation does not
|
|
||||||
apply to explicitly registered or explicitly imported bean classes.
|
|
||||||
|
|
||||||
[TIP]
|
[TIP]
|
||||||
====
|
====
|
||||||
Another way of accessing differently scoped target beans is an `ObjectFactory`/
|
Another way of accessing differently scoped target beans is an `ObjectFactory`/
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2023 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -565,9 +565,10 @@ public class ClassPathScanningCandidateComponentProvider implements EnvironmentC
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether the given bean definition qualifies as candidate.
|
* Determine whether the given bean definition qualifies as a candidate component.
|
||||||
* <p>The default implementation checks whether the class is not an interface
|
* <p>The default implementation checks whether the class is not dependent on an
|
||||||
* and not dependent on an enclosing class.
|
* enclosing class as well as whether the class is either concrete (and therefore
|
||||||
|
* not an interface) or has {@link Lookup @Lookup} methods.
|
||||||
* <p>Can be overridden in subclasses.
|
* <p>Can be overridden in subclasses.
|
||||||
* @param beanDefinition the bean definition to check
|
* @param beanDefinition the bean definition to check
|
||||||
* @return whether the bean definition qualifies as a candidate component
|
* @return whether the bean definition qualifies as a candidate component
|
||||||
|
|
Loading…
Reference in New Issue