• Duboo 与springboot整合


       https://github.com/apache/incubator-dubbo-spring-boot-project    

    当采用properties方式时,可以用下方的注解

    1.pom 

        <dependencies>
    <dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>dubbo</artifactId>
    <version>2.6.2</version>
    </dependency>

    <dependency>
    <groupId>org.apache.zookeeper</groupId>
    <artifactId>zookeeper</artifactId>
    <version>3.4.11</version>
    <exclusions>
    <exclusion>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    </exclusion>
    </exclusions>
    </dependency>

    <dependency>
    <groupId>org.apache.curator</groupId>
    <artifactId>curator-framework</artifactId>
    <version>2.12.0</version>
    </dependency>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter</artifactId>
    </dependency>

    <dependency>
    <groupId>org.apache.dubbo</groupId>
    <artifactId>dubbo-spring-boot-starter</artifactId>
    <version>2.7.0</version>
    </dependency>
    </dependencies>

    2.yml 初步配置

    dubbo:
    application:
    name: bootprovide

    registry:
    address: 127.0.0.1:2181
    protocol: zookeeper

    protocol:
    name: dubbo
    port: 20880

    3.service (要用dubbo包的) ==>> 暴露服务

    4.启动类 加上      @EnableDubbo

    package com.abc;
    
    import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    @EnableDubbo
    @SpringBootApplication
    public class BootProvideApplication {
    
        public static void main(String[] args) {
            SpringApplication.run(BootProvideApplication.class, args);
        }
    
    }

     二、消费者

    @Reference  自动注入

     @Reference 注入远程服务对象 和@Autowired作用相似

  • 相关阅读:
    Jenkins参数化构建
    python笔记
    jenkins定时任务
    技巧:Vimdiff 使用
    clover如何使用UEFI引导和EFI驱动选择
    Broadcast BCM94322 用ubuntu修改ID
    MAC实现睡眠和休眠唤醒
    MAC的睡眠模式介绍
    linux 用dd命令读写引导区文件
    MAC下打开FTP服务
  • 原文地址:https://www.cnblogs.com/mm163/p/10650636.html
Copyright © 2020-2023  润新知