Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support module path scanning for "classpath*:" resource prefix #28506

Closed
sbrannen opened this issue May 23, 2022 · 1 comment
Closed

Support module path scanning for "classpath*:" resource prefix #28506

sbrannen opened this issue May 23, 2022 · 1 comment
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) in: test Issues in the test module type: enhancement A general enhancement
Milestone

Comments

@sbrannen
Copy link
Member

sbrannen commented May 23, 2022

In light of the findings from investigating #21515, we should introduce implicit support for scanning the module path whenever the classpath*: resource prefix is used.

This should allow existing applications relying on classpath*: semantics to work when migrating to the Java module system (for use cases not already supported by ClassLoader-based class path scanning).

For example, @ComponentScan should effectively work the same when an application is deployed on the class path or module path.

@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement labels May 23, 2022
@sbrannen sbrannen added this to the 6.0.0-M5 milestone May 23, 2022
@sbrannen sbrannen self-assigned this May 23, 2022
sbrannen added a commit to sbrannen/spring-framework that referenced this issue May 23, 2022
Prior to this commit, searching for classpath resources using the
"classpath*:" resource prefix did not find all applicable resources for
applications deployed as modules -- for example, when test classes and
resources are patched into the application module automatically by
Maven Surefire.

This affected component scanning -- for example, via [@]ComponentScan --
and PathMatchingResourcePatternResolver.getResources(String) in
general.

This commit addresses this by introducing first-class support for
scanning the module path when PathMatchingResourcePatternResolver's
getResources(String) method is invoked with a location pattern using
the "classpath*:" resource prefix. Specifically, getResources(String)
first searches all modules in the boot layer, excluding system modules.
It then searches the classpath using the existing Classloader-based
algorithm and returns the combined results.

Closes spring-projectsgh-28506
@sbrannen
Copy link
Member Author

This issue has been resolved for inclusion in 6.0 M5.

In the interim, feel free to try out 6.0 snapshots for applications deployed with patched modules.

I've created a new repository for demonstrating the use of the Spring Framework with the Java Module System: https://github.com/sbrannen/spring-module-system

That repository currently contains a single maven-surefire-patched-module project which demonstrates support for @ComponentScan in a patched module using Maven Surefire.

@sbrannen sbrannen added the in: test Issues in the test module label May 25, 2022
sdeleuze added a commit to sdeleuze/spring-framework that referenced this issue Sep 21, 2022
spring-projectsgh-28506 introduces a big footprint regression on
native, so it should for now be skipped when
compiling to native images. Such support could
potentially be re-introduced via spring-projectsgh-29081.

Closes spring-projectsgh-29183
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) in: test Issues in the test module type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant