spring-boot下搭建dubbo+zookeeper(一)

下载zookeeper

config目录去把zookeeper_sample.cfg改名为zookeeper.cfg

修改bin目录下的zkEnv.cmd文件,set ZOOFG

启动,打开bin目录下的zkServer.cmd,如出现闪退,在zkServer加上pause

启动完成如下

下载dubbo-2.6.0

修改D:\dubbo\dubbo-dubbo-2.6.0\dubbo-admin\src\main\webapp\WEB-INF的dubbo.properties

dubbo.registry.address=zookeeper://127.0.0.1:2181
dubbo.admin.root.password=root
dubbo.admin.guest.password=guest

  dobbo admin安装

在cmd下找到D:\dubbo\dubbo-dubbo-2.6.0\dubbo-admin

打包完成之后D:\dubbo\dubbo-dubbo-2.6.0\dubbo-admin下就有了target这个文件夹

把dubbo-admin-2.6.0war复制到tomcat的webapps文件加下

tomcat的bin目录启动startup.bat

建个Maven项目

首先dobbo-api

entity

package com.dubbo.entity;

import java.io.Serializable;

public class People implements Serializable {
    /**
     * 
     */
    private static final long serialVersionUID = 1415852192397895853L;
    // 人员编号
    private int id;
    // 姓名
    private String name;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "People [id=" + id + ", name=" + name + "]";
    }

}

sevcie包

package com.dubbo.service;

import com.dubbo.entity.People;

public interface PeopleService {
	
	People getPeople(People people);
}

启动文件

package com.dubbo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;

@SpringBootApplication
@EnableDubbo
public class Start {
	public static void main(String[] args) {
		SpringApplication.run(Start.class, args);
	}
}

 application.properties

server.port=8887

pom

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.pp</groupId>
  <artifactId>dubbo-api</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  
   <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.12.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
  <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>
    
     <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.alibaba.boot/dubbo-spring-boot-project -->
        <dependency>
            <groupId>com.alibaba.boot</groupId>
            <artifactId>dubbo-spring-boot-starter</artifactId>
            <version>0.1.0</version>
        </dependency>
        </dependencies> 
</project>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值