HttpInvokerServiceExporter 在 spring 5 中已弃用。我想通过 HTTP 协议调用 spring 远程 bean。有替代品吗? HttpInvokerServiceExporter 也有一个 RCE 漏洞,所以我需要使用一些 HttpInvokerServiceExporter 的替代品。
RMI骨架
@Configuration
public class RMIServer {
@Bean
DTBookingService bookingService() {
return new DTBookingServiceImpl();
}
@Bean(name = "exporter")
RmiServiceExporter exporter(DTBookingService implementation) {
Class<DTBookingService> serviceInterface = DTBookingService.class;
RmiServiceExporter exporter = new RmiServiceExporter();
exporter.setServiceInterface(serviceInterface); //interface
exporter.setService(implementation); //bean
exporter.setServiceName("bookingService"); //bean name
exporter.setRegistryPort(1099);
try {
exporter.prepare();
} catch (RemoteException e) {
e.printStackTrace();
}
return exporter;
}
}
RMI 存根调用远程 bean 导入 javax.naming.Context;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.remoting.rmi.RmiProxyFactoryBean;
@Configuration
public class RMIClientConfig {
@Bean
RmiProxyFactoryBean service() {
RmiProxyFactoryBean proxyFactoryBean = new RmiProxyFactoryBean();
proxyFactoryBean.setServiceUrl("rmi://localhost:1099/bookingService");
proxyFactoryBean.setServiceInterface(DTBookingService.class);
return proxyFactoryBean;
}
}
现在我尝试通过 http 协议而不是 rmi://(RmiServiceExporter) 通过 HttpInvokerServiceExporter 调用 bean。请建议是否需要替换 HttpInvokerServiceExporter。
根据
https://docs.spring.io/spring-framework/docs/6.0.7/javadoc-api/
整个软件包分支
org.springframework.remoting
不适用于 Spring 6。