@Configurationmore determined than @ComponentScanin all cases.
Instead of going around the annotation @ComponentScan. You should try to explicitly specify yours MyClass.classin the class @Configurationas @Bean, for example:
@Configuration
public class MyClassConfiguraiton {
@Bean
public MyClass myClass() {
return new MyClass();
}
}
@Import @ComponentScan:
@Import(MyClassConfiguratrion.class)
( @Configuration - @Component).