I have the following setting for my Spring Application Context .
@Configuration public class RmiContext { @Bean public RmiProxyFactoryBean service() { RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean(); rmiProxy.setServiceUrl("rmi://127.0.1.1:1099/Service"); rmiProxy.setServiceInterface(Service.class); return rmiProxy; } }
@Configuration public class LocalContext { @Bean public Controller Controller() { return new ControllerImpl(); } }
@Configuration @Import({RmiContext.class, LocalContext.class}) public class MainContext {
}
The above setup works fine, but I want to enable the @ComponentScan annotation of the Controller using @Component , since my application has a lot of Controller , which is tedious when declared one by one using @Bean .
@Configuration @ComponentScan(basePackageClasses = {Controller.class}) public class LocalContext { }
The problem is that when I do
@ComponentScan(basePackageClasses = {Controller.class}) , the previously fine working
RmiProxyFactoryBean are not recognized or can't be created.
So, how do I configure my MainContext to create beans through RMI and local beans?
source share