Spring RMI : How to expose without App server or servlet container?

标签 spring spring-remoting

我有很多通过 RMI 和 Spring 公开的服务。目前,我的应用程序配置为 Web 应用程序,并将我的应用程序部署到 JBoss 以使我的 RMI 服务可用。有没有一种方法可以运行我的 RMI 公开服务,而无需将我的应用程序设为 Web 应用程序?

最佳答案

是的,只需在“普通”(读取:非 webapp)应用程序中实例化您的 Spring 应用程序上下文并为其定义您的服务和导出器:

<bean id="myService" class="my.example.MyServiceImpl">
    <!-- properties -->
</bean>

<bean class="org.springframework.remoting.rmi.RmiServiceExporter">
    <!-- does not necessarily have to be the same name as the bean to be exported -->
    <property name="serviceName" value="myRMIService"/>
    <property name="service" ref="myService"/>
    <property name="serviceInterface" value="my.example.MyService"/>
    <!-- defaults to 1099 -->
    <property name="registryPort" value="1199"/>
</bean

这样您的服务将在 rmi://HOST:1199/myRMIService 上可用。

阅读有关 RMI 的完整文档 here 。如果您不熟悉如何实例化 Spring 上下文,请阅读 here .

关于 Spring RMI : How to expose without App server or servlet container?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6389076/

相关文章:

java - 编译时没有调试信息的含义

java - Hibernate不自动生成表

java - Spring Boot-Hibernate-Mysql id 主键值序列使用@GeneratedValue 在我的所有域中共享

java - 如何找出用于 hibernate 中特定查询的事务隔离级别?

java - Spring - 无法反序列化来自 HTTP 调用者远程服务的结果

java - 无法反序列化 HTTP 调用程序远程服务的结果 [...];嵌套异常是 java.lang.ClassNotFoundException :

spring - RMI 服务导出器和 HttpInvoker 之间的区别?

java - 使用 Spring @Configuration 注释注入(inject) bean 列表

Spring Remoting HTTP 调用程序 - 异常处理