I have a configuration class
@Configuration
public class FooConfig{
@Bean
public FooService fooService() { ... }
@Bean
public AbcService abcService() { ... }
}
That class is defined in a lib that I can't change. I have a project where FooService
is used in many places. In my project I have another configuration class
@Configuration
@Import({
FooConfig.class,
})
public class BarConfig{
@Autowired AbcService abc;
...
}
AbcService
is used here because there are services which depends on that service and those services are declared in BarConfig
. However, FooService
is not used here(it is used only in controllers)
I need to change the implementation of FooService
. Can I define new FooService
bean in BarConfig
? Will it override already present definition which is imported via FooConfig
?