Hessian学习(3)——客户端使用spring
来源:互联网 发布:上海老年人口 知乎 编辑:程序博客网 时间:2024/05/16 03:50
上一篇文章Hessian学习(2)——整合spring中服务端整合了spring,但是客户端没有,本文将总结一下客户端也加入spring的使用方法。
1.服务端代码不用变,仍然使用HessianServer2;
2.新建一个客户端项目,此处命名为HessianClient2_2;
3.导入相关jar包,此处为:
hessian-4.0.7.jarjunit-4.10.jarspring-beans-3.1.1.RELEASE.jarspring-context-3.1.1.RELEASE.jarspring-context-support-3.1.1.RELEASE.jarspring-core-3.1.1.RELEASE.jar
4.在src下新建一个spring管理文件,命名为:hessian-client.xml:
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"><!-- 客户端Hessian代理工厂Bean --> <bean id="myClient" class="org.springframework.remoting.caucho.HessianProxyFactoryBean"> <!-- 地址 --> <property name="serviceUrl"> <value>http://localhost:28080/HessianServer2/hessian/hello</value> </property> <!-- 接口定义 --> <property name="serviceInterface"> <value>包名.HelloService</value> </property> </bean></beans>
5.创建一个测试类:
public class SpringHessianTest {@Testpublic void testSpringHessian() {try {ApplicationContext context = new ClassPathXmlApplicationContext("hessian-client.xml");HelloService service = context.getBean(HelloService.class);System.out.println(service.helloWorld("spring client!"));} catch (Exception e) {e.printStackTrace();}}}6.测试结果如下:
总结:无
代码路径:csdn code
0 0
- Hessian学习(3)——客户端使用spring
- Hessian学习(2)——整合spring
- Hessian学习总结(二)——使用hessian上传文件
- 《Spring技术内幕》学习笔记18——Spring使用Hessian实现远程调用
- 《Spring技术内幕》学习笔记18——Spring使用Hessian实现远程调用
- 《Spring技术内幕》学习笔记18——Spring使用Hessian实现远程调用
- 《Spring技术内幕》学习笔记18——Spring使用Hessian实现远程调用
- 《Spring技术内幕》学习笔记18——Spring使用Hessian实现远程调用
- 《Spring技术内幕》学习笔记18——Spring使用Hessian实现远程调用
- 《Spring技术内幕》学习笔记18——Spring使用Hessian实现远程调用
- Hessian知识学习总结(三)——Spring + Hessian + Spring MVC
- Hessian学习(1)——基本使用
- Hessian学习(4)——正常使用
- Spring框架学习【Spring使用Hessian实现远程调用】
- hessian + spring 使用
- Hessian学习总结(一)——Hessian入门
- Hessian学习总结(一)——Hessian入门
- spring整合hessian学习笔记
- C++多行文本读取
- shell批量插入redis测试数据
- MongoDB学习日记 - java代码(七):runCommand & BasicDBObject
- 全路径搜索策略
- Tiny6410裸机开发实验----重定位代码到DRAM
- Hessian学习(3)——客户端使用spring
- ZOJ.2105 Number Sequence【数论-快速幂矩阵】 2015/09/16
- 测试前7章总结
- 验证码| 在一般处理程序中使用Session
- tomcat 设置安全访问
- 原生js+JQuery在浏览器之间兼容的坑
- zufe oj 免费的pizza (简单DP)
- HDU 5120 Intersection
- 生成Excel