Document placeholder and pattern support for @⁠ComponentScan

- JavaDoc: clarify that basePackages/value resolve ${…} via Environment
  and accept Ant-style package patterns (e.g., com.example.**); note
  patterns don’t apply to basePackageClasses.

- Reference: add “Property placeholders and Ant-style patterns”
  subsection in classpath-scanning.adoc with Java/Kotlin + properties
  examples.

See gh-35288
Closes gh-35491

Signed-off-by: Byeong-Uk Park <114344042+Rockernun@users.noreply.github.com>
This commit is contained in:
Byeong-Uk Park
2025-09-18 18:00:11 +02:00
committed by Sam Brannen
parent 015edb33cd
commit fe04bfcadb
2 changed files with 52 additions and 0 deletions
@@ -323,6 +323,45 @@ sure that they are 'opened' (that is, that they use an `opens` declaration inste
`exports` declaration in your `module-info` descriptor).
====
==== Property placeholders and Ant-style patterns
`@ComponentScan(basePackages)` supports `${…}` property placeholders resolved
against the `Environment` and Ant-style package patterns such as `com.example.**`.
Multiple packages and/or patterns may be specified.
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes"]
----
@Configuration
@ComponentScan(basePackages = "${app.scan.packages}")
public class AppConfig {
// ...
}
----
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
@Configuration
@ComponentScan(basePackages = ["\${app.scan.packages}"])
class AppConfig {
// ...
}
----
======
[source,properties,indent=0,subs="verbatim,quotes"]
----
app.scan.packages=com.example.**,org.acme.*
----
NOTE: Ant-style patterns do not apply to `basePackageClasses`, which accepts concrete
classes and derives packages from those classes.
Furthermore, the `AutowiredAnnotationBeanPostProcessor` and
`CommonAnnotationBeanPostProcessor` are both implicitly included when you use the
component-scan element. That means that the two components are autodetected and