Skip to content

Commit a9453a5

Browse files
committed
Polishing
1 parent 3781ba2 commit a9453a5

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

framework-docs/modules/ROOT/pages/core/beans/classpath-scanning.adoc

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
[[beans-classpath-scanning]]
22
= Classpath Scanning and Managed Components
33

4-
Most examples in this chapter use XML to specify the configuration metadata that produces
5-
each `BeanDefinition` within the Spring container. The previous section
6-
(xref:core/beans/annotation-config.adoc[Annotation-based Container Configuration]) demonstrates how to provide a lot of the configuration
7-
metadata through source-level annotations. Even in those examples, however, the "base"
8-
bean definitions are explicitly defined in the XML file, while the annotations drive only
9-
the dependency injection. This section describes an option for implicitly detecting the
10-
candidate components by scanning the classpath. Candidate components are classes that
11-
match against a filter criteria and have a corresponding bean definition registered with
12-
the container. This removes the need to use XML to perform bean registration. Instead, you
13-
can use annotations (for example, `@Component`), AspectJ type expressions, or your own
4+
Most examples in this chapter use XML to specify the configuration metadata that
5+
produces each `BeanDefinition` within the Spring container. The previous section
6+
(xref:core/beans/annotation-config.adoc[Annotation-based Container Configuration])
7+
demonstrates how to provide a lot of the configuration metadata through source-level
8+
annotations. Even in those examples, however, the "base" bean definitions are explicitly
9+
defined in the XML file, while the annotations drive only the dependency injection.
10+
11+
This section describes an option for implicitly detecting the candidate components by
12+
scanning the classpath. Candidate components are classes that match against a filter
13+
criteria and have a corresponding bean definition registered with the container.
14+
This removes the need to use XML to perform bean registration. Instead, you can use
15+
annotations (for example, `@Component`), AspectJ type expressions, or your own
1416
custom filter criteria to select which classes have bean definitions registered with
1517
the container.
1618

1719
[NOTE]
1820
====
1921
You can define beans using Java rather than using XML files. Take a look at the
20-
`@Configuration`, `@Bean`, `@Import`, and `@DependsOn` annotations for examples of how to
21-
use these features.
22+
`@Configuration`, `@Bean`, `@Import`, and `@DependsOn` annotations for examples
23+
of how to use these features.
2224
====
2325

2426

@@ -830,10 +832,10 @@ definitions, there is no notion of bean definition inheritance, and inheritance
830832
hierarchies at the class level are irrelevant for metadata purposes.
831833

832834
For details on web-specific scopes such as "`request`" or "`session`" in a Spring context,
833-
see xref:core/beans/factory-scopes.adoc#beans-factory-scopes-other[Request, Session, Application, and WebSocket Scopes]. As with the pre-built annotations for those scopes,
834-
you may also compose your own scoping annotations by using Spring's meta-annotation
835-
approach: for example, a custom annotation meta-annotated with `@Scope("prototype")`,
836-
possibly also declaring a custom scoped-proxy mode.
835+
see xref:core/beans/factory-scopes.adoc#beans-factory-scopes-other[Request, Session, Application, and WebSocket Scopes].
836+
As with the pre-built annotations for those scopes, you may also compose your own scoping
837+
annotations by using Spring's meta-annotation approach: for example, a custom annotation
838+
meta-annotated with `@Scope("prototype")`, possibly also declaring a custom scoped-proxy mode.
837839

838840
NOTE: To provide a custom strategy for scope resolution rather than relying on the
839841
annotation-based approach, you can implement the
@@ -875,7 +877,8 @@ Kotlin::
875877
----
876878

877879
When using certain non-singleton scopes, it may be necessary to generate proxies for the
878-
scoped objects. The reasoning is described in xref:core/beans/factory-scopes.adoc#beans-factory-scopes-other-injection[Scoped Beans as Dependencies].
880+
scoped objects. The reasoning is described in
881+
xref:core/beans/factory-scopes.adoc#beans-factory-scopes-other-injection[Scoped Beans as Dependencies].
879882
For this purpose, a scoped-proxy attribute is available on the component-scan
880883
element. The three possible values are: `no`, `interfaces`, and `targetClass`. For example,
881884
the following configuration results in standard JDK dynamic proxies:

0 commit comments

Comments
 (0)