我想通过SpringRMI获取远程对象:
@Configuration
public class RMIConfigBean {
@Bean
public NameService nameService() {
RmiProxyFactoryBean rmi = new RmiProxyFactoryBean();
rmi.setServiceUrl("rmi://localhost:8000/NameService");
rmi.setServiceInterface(NameService.class);
return (NameService) rmi.getObject();
}
}
但实际上rmi.getObject()
返回null,因此nameService
的后续注入失败。我错过了什么?谢谢!
答案 0 :(得分:1)
正如M.Deinum所说,我应该先致电afterPropertiesSet
。