Skip to content

Do not fail with a circular @Import error caused by an @ComponentScan [SPR-14517] #19086

Closed
@spring-projects-issues

Description

@spring-projects-issues

Jean-Pierre Bergamin opened SPR-14517 and commented

This ticket is a follow up on #17692:

We're facing a "Configuration problem: A circular @Import has been detected" error when upgrading from Spring Boot 1.3.1 to 1.3.5.

Our case is like:

A shared repository maven module contains:

@Configuration
@ComponentScan
MyRepositoryContextConfiguration {
}
@Configuration
@Import(MyRepositoryContextConfiguration.class)
MyRepositoryTestConfiguration {
}

A webapp using this shared repository (including it as a test-jar as well) has:

@Configuration
@Import(MyRepositoryTestConfiguration)
MyWebappTestConfiguration {
}

The component scan in the MyRepositoryContextConfiguration class picks up the MyRepositoryTestConfiguration again when running tests and leads to the following error:

Configuration problem: A circular @Import has been detected: Illegal attempt by @Configuration class 'MyRepositoryTestConfiguration' to import class 'MyRepositoryTestConfiguration' as 'MyRepositoryTestConfiguration' is already present in the current import stack [MyRepositoryTestConfiguration->MyWebappTestConfiguration]

A @ComponentScan should not trigger this error since it's not an explicit @Import definition.


Affects: 4.2.6

Reference URL: https://jira.spring.io/browse/SPR-13101?focusedCommentId=130875&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-130875

Issue Links:

Backported to: 4.2.8

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions