zoukankan      html  css  js  c++  java
  • SpringBoot整合Dubbo

    一、导入依赖

      

    二、生产者provider

      (1)目录展示

          

      (2)配置文件application.properties

          

      (3)DoSomeService接口     

    package com.zn.service;
    
    public interface DoSomeService {
        public String sayHi();
    }

      (4)DoSomeServiceImpl实现类

    package com.zn.service.impl;
    
    
    import com.alibaba.dubbo.config.annotation.Service;
    import com.zn.service.DoSomeService;
    import org.springframework.stereotype.Component;
    
    @Service(interfaceClass = DoSomeService.class)
    @Component
    public class DoSomeServiceImpl implements DoSomeService{
        @Override
        public String sayHi() {
            System.out.println("生产者生产的IDoSomeService服务,中的sayHi方法");
            return "SpringBoot Dubbo";
        }
    }

      (5)测试类StartDubbo

          

    四、消费者consumer

      (1)目录展示

          

      (2)配置文件application.properties

           

      (3)DoSomeService接口 

    package com.zn.service;
    
    public interface DoSomeService {
        public String sayHi();
    }

      (4)DubboController

    package com.zn.controller;
    
    import com.alibaba.dubbo.config.annotation.Reference;
    import com.zn.service.DoSomeService;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;
    
    @RestController
    public class DubboController {
    
        @Reference
        private DoSomeService doSomeService;
    
        @RequestMapping("/dubbo")
        public String dubbo(){
            String returnValue = doSomeService.sayHi();
           return returnValue;
        }
    }

      (5)测试类

         

     五、效果展示

      

      

       

  • 相关阅读:
    web前端性能意义、关注重点、测试方案、优化技巧
    前端性能优化和规范
    高性能网站性能优化与系统架构(ZT)
    【转载】12306铁道部订票网站性能分析
    构架高性能WEB网站的几点知识
    减少图片HTTP 请求的方案
    网站性能优化:动态缩略图技术实现思路
    不错的jquery插件
    jQuery 遍历
    JavaScript slice() 方法
  • 原文地址:https://www.cnblogs.com/Zzzzn/p/12039068.html
Copyright © 2011-2022 走看看