SpringMVC使用Burlap发布远程服务

时间:2023-12-14 16:57:26

参考这篇文章https://www.cnblogs.com/fanqisoft/p/10283156.html

将提供者配置类中的

     @Bean
public HessianServiceExporter hessianExporterUserService(UserService userService){
HessianServiceExporter hessianServiceExporter = new HessianServiceExporter();
hessianServiceExporter.setService(userService);
hessianServiceExporter.setServiceInterface(UserService.class);
return hessianServiceExporter;
}

替换为

     @Bean
public BurlapServiceExporter burlapExportedUserService(UserService userService){
BurlapServiceExporter burlapServiceExporter = new BurlapServiceExporter();
burlapServiceExporter.setService(userService);
burlapServiceExporter.setServiceInterface(UserService.class);
return burlapServiceExporter;
}

将服务消费者

     @Bean
public HessianProxyFactoryBean userService(){
HessianProxyFactoryBean proxy = new HessianProxyFactoryBean();
proxy.setServiceUrl("http://localhost:8081/SpringRmiService_war_exploded/user.service");
proxy.setServiceInterface(UserService.class);
return proxy;
}

替换为

     @Bean
public BurlapProxyFactoryBean userService(){
BurlapProxyFactoryBean proxy = new BurlapProxyFactoryBean();
proxy.setServiceUrl("http://localhost:8081/SpringRmiService_war_exploded/user.service");
proxy.setServiceInterface(UserService.class);
return proxy;
}