Closed
Description
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
Issue Links:
- ConfigurationClassParser needs to load annotations through source class loader [SPR-10343] #14977 ConfigurationClassParser needs to load annotations through source class loader
- Spring does not reliably detect circular imports in Java configurations [SPR-13852] #18425 Spring does not reliably detect circular imports in Java configurations
- @Bean not detected in extended interface [SPR-14288] #18860
@Bean
not detected in extended interface - Improve circular import exception, in particular for @Import vs import through nesting [SPR-13101] #17692 Improve circular import exception, in particular for
@Import
vs import through nesting
Backported to: 4.2.8