Skip to content

Conversation

Rockernun
Copy link
Contributor

@Rockernun Rockernun commented Sep 17, 2025

Overview

@ComponentScan(basePackages) already supports:

  • Resolving ${…} property placeholders against the Spring Environment.
  • Ant-style package patterns (e.g., com.example.**, org.acme.*).

However, this behavior wasn’t explicitly called out in the JavaDoc or the reference docs, making it easy to miss. This PR documents those capabilities and clarifies where pattern support applies.

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

Reference docs: add a short subsection in classpath-scanning.adoc with Java/Kotlin + properties examples.

Related Issues

…onentscan

- 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.

Closes spring-projectsgh-35288

Signed-off-by: Byeong-Uk Park <114344042+Rockernun@users.noreply.github.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Sep 17, 2025
@sbrannen sbrannen added type: documentation A documentation task in: core Issues in core modules (aop, beans, core, context, expression) labels Sep 17, 2025
@sbrannen sbrannen self-assigned this Sep 17, 2025
@sbrannen sbrannen changed the title docs(core): document ${…} placeholders & Ant-style patterns for @ComponentScan Document ${…} placeholders & Ant-style patterns for @ComponentScan Sep 17, 2025
@sbrannen sbrannen removed the status: waiting-for-triage An issue we've not yet triaged or decided on label Sep 18, 2025
@sbrannen sbrannen added this to the 7.0.0-RC1 milestone Sep 18, 2025
Copy link
Member

@sbrannen sbrannen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few notes, but I am approving this PR as-is, since I have made the necessary changes locally on my machine.

`exports` declaration in your `module-info` descriptor).
====

==== Property placeholders and Ant-style patterns
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that this breaks the build.

[16:49:49.179] WARN (asciidoctor): section title out of sequence: expected level 2, got level 3
    file: /XXX/spring-framework/framework-docs/modules/ROOT/pages/core/beans/classpath-scanning.adoc:335

However, I have addressed this locally, thus there is no need to update this PR.


NOTE: Ant-style patterns do not apply to `basePackageClasses`, which accepts concrete
classes and derives packages from those classes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: the following paragraph and note belong to the previous section about XML configuration.

However, I have addressed this locally, thus there is no need to update this PR.

Comment on lines +97 to +99
* <p><strong>Note:</strong> Ant-style patterns are <em>not</em> applicable to
* {@link #basePackageClasses()}, which accepts concrete classes for type-safe
* package selection.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is any need to point this out, since one can only supply Class references via the basePackageClasses attribute.

Thus, I have removed this and other such text locally.

`exports` declaration in your `module-info` descriptor).
====

==== Property placeholders and Ant-style patterns
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future reference, please note that we do our best to introduce custom anchors that align with other anchors used in the same file.

For example, I've added the following that I will apply after merging this PR.

[[beans-scanning-placeholders-and-patterns]]

@sbrannen sbrannen changed the title Document ${…} placeholders & Ant-style patterns for @ComponentScan Document placeholder and Ant-style pattern support for @ComponentScan Sep 18, 2025
@sbrannen sbrannen closed this in fe04bfc Sep 18, 2025
sbrannen added a commit that referenced this pull request Sep 18, 2025
@sbrannen
Copy link
Member

This has been merged into main in fe04bfc and revised in dbb9bf9

Thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: documentation A documentation task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants