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

JDK11: @ComponentScan doesn't work properly in JUnit tests #18516

Closed
sergey-derugo opened this issue Oct 6, 2019 · 1 comment
Closed

JDK11: @ComponentScan doesn't work properly in JUnit tests #18516

sergey-derugo opened this issue Oct 6, 2019 · 1 comment
Labels
for: external-project For an external project and not something we can fix status: duplicate A duplicate of another issue

Comments

@sergey-derugo
Copy link

sergey-derugo commented Oct 6, 2019

@ComponentScan cannot detect components in sub-packages if module-info.java(JDK11) presents in the sources.

Steps to reproduce:

  1. Use Spring Boot 2.1.9.RELEASE and JDK 11.0.4
  2. Download the sample
  3. Run mvn clean test

Actual result:

  • org.springframework.beans.factory.UnsatisfiedDependencyException is thrown, see the attached stack trace.

Expected result:

  • All tests passed.

Workarounds:

  1. Remove module-info.java
  2. Use @Import instead of @ComponentScan , see com.example.demo.ServiceModuleConfiguration in the attached sample
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 6, 2019
@wilkinsona
Copy link
Member

Thanks for the report. This is a duplicate of spring-projects/spring-framework#21515.

@wilkinsona wilkinsona added for: external-project For an external project and not something we can fix status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 6, 2019
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

3 participants