Skip to content

ComponentScan probably works differently since 3.2 or has a bug? #38845

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

Closed
hugograf opened this issue Dec 17, 2023 · 5 comments
Closed

ComponentScan probably works differently since 3.2 or has a bug? #38845

hugograf opened this issue Dec 17, 2023 · 5 comments
Labels
for: external-project For an external project and not something we can fix status: duplicate A duplicate of another issue

Comments

@hugograf
Copy link

hugograf commented Dec 17, 2023

We have two classes with which we start Spring Boot, one for default (GrafioschtraderApplication) and tests (GTforTest).
Default:

...
@SpringBootApplication()
@EnableAsync
@EnableConfigurationProperties
@Configuration
@ComponentScan(basePackages = { "grafioschtrader" }, excludeFilters = {
    @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = GTforTest.class) })
public class GrafioschtraderApplication {
...

Test:

...
@SpringBootApplication()
@EnableAsync
@EntityScan(basePackages = { "grafioschtrader.entities" })
@ComponentScan(basePackages = { "grafioschtrader" }, excludeFilters = {
    @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = GrafioschtraderApplication.class) })
@PropertySource("classpath:application-test.properties")
@EnableConfigurationProperties
public class GTforTest {
...

Reading the other configuration should be excluded in these classes with @ComponentScan and excludeFiltes. This worked before Spring Boot 3.2. However, since version 3.2, application-test.properties had to be moved from src/test/resources to src/main/resources, and application-test.properties is read from the default configuration during execution. Has this behavior changed in Spring Boot 3.2 or is this a bug?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 17, 2023
@philwebb
Copy link
Member

Nothing immediately comes to mind for changes in that area. Are you able to share a sample project that reproduces the problem you're seeing?

@philwebb philwebb added the status: waiting-for-feedback We need additional information before we can continue label Dec 17, 2023
@hugograf
Copy link
Author

I have created a simple example at demo.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Dec 17, 2023
@scottfrederick
Copy link
Contributor

Thanks for the reproducer. I haven't gotten to the bottom of this yet, but it appears that the problem is fixed in the latest snapshots for Spring Boot 3.2.1. Can you try to build your real project against 3.2.1-SNAPSHOT and see if the problem still happens for you?

@scottfrederick scottfrederick added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Dec 18, 2023
@snicoll
Copy link
Member

snicoll commented Dec 19, 2023

I believe this is a duplicate of spring-projects/spring-framework#31704

@bclozel
Copy link
Member

bclozel commented Dec 19, 2023

I think that's right, I'll close this issue then as a duplicate. Thanks Scott for investigating here.

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Dec 19, 2023
@bclozel bclozel added status: duplicate A duplicate of another issue for: external-project For an external project and not something we can fix and removed status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged labels Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

6 participants