最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

spring boot整合hessian的示例

 更新時(shí)間:2017年07月18日 09:27:43   作者:sias1991  
本文通過(guò)實(shí)例代碼給大家介紹了spring boot整合hessian的方法,需要的朋友可以參考下

首先添加hessian依賴(lài)

<dependency>  
   <groupId>com.caucho</groupId>  
    <artifactId>hessian</artifactId>  
    <version>4.0.38</version>
</dependency>

服務(wù)端:HessianServer,端口號(hào):8090

public interface HelloWorldService {
  String sayHello(String name);
}
@Service("HelloWorldService")
public class HelloWorldServiceImpl implements HelloWorldService {
  @Override
  public String sayHello(String name) {
    return "Hello World! " + name;
  }
}
@SpringBootApplication
public class HessianServerApplication {
  @Autowired
  private HelloWorldService helloWorldService;
  public static void main(String[] args) {
    SpringApplication.run(HessianServerApplication.class, args);
  }
//發(fā)布服務(wù)
  @Bean(name = "/HelloWorldService")
  public HessianServiceExporter accountService() {
    HessianServiceExporter exporter = new HessianServiceExporter();
    exporter.setService(helloWorldService);
    exporter.setServiceInterface(HelloWorldService.class);
    return exporter;
  }
}

客戶(hù)端代碼:HessianClient,同服務(wù)端一樣引入hessian依賴(lài),端口號(hào):8092

public interface HelloWorldService {
  String sayHello(String name);
}
@SpringBootApplication
public class HessianClientApplication {
  @Bean
  public HessianProxyFactoryBean helloClient() {
    HessianProxyFactoryBean factory = new HessianProxyFactoryBean();
    factory.setServiceUrl("http://localhost:8090/HelloWorldService");
    factory.setServiceInterface(HelloWorldService.class);
    return factory;
  }
  public static void main(String[] args) {
    SpringApplication.run(HessianClientApplication.class, args);
  }
}
@RestController
public class TestController {
  @Autowired
  private HelloWorldService helloWorldService;
  @RequestMapping("/test")
  public String test() {
    return helloWorldService.sayHello("Spring boot with Hessian.");
  }
}

訪問(wèn)地址即可:http://localhost:8092/test

PS:springboot hessian

注意把hessian的依賴(lài)換成4.0.38或者把git文件里的4.0.37放到maven私服中去,推薦使用4.0.37版本。38版本存在序列化bigdecimal的問(wèn)題。

<dependency>
     <groupId>com.caucho</groupId>
     <artifactId>hessian</artifactId>
     <version>4.0.37</version>
  </dependency>

git:

https://git.oschina.net/wong_loong/rpc.git

以上所述是小編給大家介紹的spring boot整合hessian的示例,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論

乐都县| 龙州县| 克拉玛依市| 沧州市| 大同市| 琼结县| 建宁县| 河北省| 临沭县| 遵义市| 吴江市| 元谋县| 平昌县| 库尔勒市| 长寿区| 喀喇| 平乡县| 兰西县| 大姚县| 罗田县| 湄潭县| 井陉县| 泾阳县| 长子县| 江北区| 清流县| 勃利县| 古浪县| 陇南市| 巫山县| 南汇区| 时尚| 玉树县| 临沭县| 峨边| 新沂市| 台南市| 长治县| 新蔡县| 策勒县| 康平县|