自定义一个配置简单的rmi包
前提:防火墙中需要开放相应端口,对应spring MVC框架
采用maven install命令打包
mvn install:install-file -Dfile=C:xxxxx.jar -DgroupId=groupId -DartifactId=rmi-rest-spring-1.0 -Dversion=1.0 -Dpackaging=jar
将打包好的文件置于maven仓,并引入以下坐标
<dependency> <groupId>groupId</groupId> <artifactId>rmi-rest-spring-1.0</artifactId> <version>1.0-SNAPSHOT</version>
</dependency>
在相关xml文件中加入
<bean name="myRmiService" class="remoteForSpringMvc.ProxyFactory.ProxyFactoryCglib">
<!-- 我自己定义的类MyRmiService --> <property name="targetClass" value="packagename.MyRmiService"/>
<!-- 我要rmi的远端ip地址和端口号--> <property name="remoteBaseUrl" value="http://xxxxx:port"/> <property name="invokeType" value="rest_template"></property>
<!--验证签名--> <property name="signKey" value="11111111111"></property> <property name="needSign" value="true"></property> </bean>
MyRmiService.java
//远端对应的映射参数为rmiController.do?rmiMethod&id=xxx&code=xxxx
@Path("/rmiController.do") public interface MyRmiService { @Path("rmiMethod")
//接受远端的返回值 public Map<String,Object> getMateriel(@PostSub("id") String id,@PostSub("code")); }
链接: https://pan.baidu.com/s/1sm51bR3 密码: 8iqt

浙公网安备 33010602011771号