一、安装前准备

  由于dubbo被阿里捐献给了apache,这次安装admin时,参考网上的资料,地址还是停留在之前的链接,踩了不少坑,这里记录下。

  dubbo-admin下载地址:

  地址一:https://github.com/apache/incubator-dubbo/releases

    该地址2.6版本以上的包中没有dubbo-admin ,2.5x版本的有

  地址二:https://github.com/apache/incubator-dubbo-ops

    该地址中的dubbo-admin模块被单独拎出来了,springboot方式启动,可以直接运行main方法,或者使用 java -jar 方式启动,很方便,有github账号的可以fork一下,推荐使用这个版本,本文介绍的就是该版本  。

二、dubbo-spring-boot-starter的使用

  github地址:https://github.com/alibaba/dubbo-spring-boot-starter 最新版本为2.0 ,本文也是使用的该版本。

2.1、添加依赖

    <dependency>
<groupId>com.alibaba.spring.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>

2.2、新建接口模块

  目录结构

  接口类

package com.dc.sb.service;

public interface RemoteUserService {

    String sayHello(String name);

}

2.3、新建provider模块

  目录结构

  接口实现类

package com.dc.sb.dubbo.provider.service.user;

import com.alibaba.dubbo.config.annotation.Service;
import com.dc.sb.service.RemoteUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component; /**
* dubbo 服务service
*
* @author DUCHONG
* @since 2018-07-03 18:29
**/
@Component
@Service(version = "1.0.0",timeout = 10000,interfaceClass = RemoteUserService.class)
public class RemoteUserServiceImpl implements RemoteUserService { private static final Logger logger = LoggerFactory.getLogger(RemoteUserServiceImpl.class); @Override
public String sayHello(String name) { return "Hello "+name;
}
}

  配置文件

server.port=8081
server.context-path=/ spring.application.name=dubbo-spring-boot-starter
spring.dubbo.server=true
spring.dubbo.registry=zookeeper://127.0.0.1:2181

  启动类

package com.dc.sb.dubbo.provider;

import com.alibaba.dubbo.spring.boot.annotation.EnableDubboConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication
@EnableDubboConfiguration
public class SbDubboProviderApplication { public static void main(String[] args) {
SpringApplication.run(SbDubboProviderApplication.class, args);
}
}

2.4、 消费者模块

  目录结构

  启动类

package com.dc.sb.web;

import com.alibaba.dubbo.spring.boot.annotation.EnableDubboConfiguration;
import com.dc.sb.config.DruidProperties;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan; @SpringBootApplication
@EnableConfigurationProperties({DruidProperties.class})
@MapperScan(basePackages = "com.dc.sb.dao")
@ComponentScan("com.dc.sb.*")
@EnableDubboConfiguration
public class SbWebApplication { public static void main(String[] args) {
SpringApplication.run(SbWebApplication.class, args);
}
}

  配置文件

#server
server.port=8080
server.context-path=/ #mybatis
mybatis.type-aliases-package= com.dc.sb.dao.dataobject
mybatis.mapper-locations= classpath*:META-INF/mybatis/mapper/*.xml #druid
druid.initialSize= 5
druid.minIdle= 0
druid.maxActive= 20
druid.maxWait= 6000
druid.timeBetweenEvictionRunsMillis= 60000
druid.minEvictableIdleTimeMillis= 300000
druid.validationQuery= SELECT 1 FROM DUAL
druid.testWhileIdle= false
druid.testOnBorrow= false
druid.testOnReturn= false
druid.poolPreparedStatements= true
druid.maxPoolPreparedStatementPerConnectionSize= 20
druid.filters= stat,log4j #mysql
spring.datasource.driver-class-name= com.mysql.jdbc.Driver
spring.datasource.url= jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&allowMultiQueries=true
spring.datasource.username= root
spring.datasource.password=root #redis
spring.redis.host=127.0.0.1
spring.redis.port=6379
spring.redis.password=redis #dubbo
spring.application.name=dubbo-spring-boot-starter
spring.dubbo.registry=zookeeper://127.0.0.1:2181

  引用端

package com.dc.sb.web.controller.remote;

import com.alibaba.dubbo.config.annotation.Reference;
import com.dc.sb.service.RemoteUserService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; /**
* dubbo消费者controller
* @author DUCHONG
* @since 2018-07-03 18:44
**/
@RestController
public class RemoteUserController { //timeout 可以不指定,但是version一定要指定 不然会找不到服务 直连需要加url="dubbo://localhost:20880"
@Reference(version = "1.0.0")
private RemoteUserService remoteUserService; @RequestMapping(value="/dubbo/say/{name}")
public String sayHello(@PathVariable("name") String name){ String result=remoteUserService.sayHello(name);
return result;
} }

三、dubbo-admin的启动

下载地址二的包,直接在idea中打开,结构如下:

install完成之后,直接右键DubboAdminApplication  Run

修改配置文件,位置在 dubbo-admin /src/main/resource下面

#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# server.port=7001
spring.velocity.cache=false
spring.velocity.charset=UTF-8
spring.velocity.layout-url=/templates/default.vm
spring.messages.fallback-to-system-locale=false
spring.messages.basename=i18n/message
spring.root.password=root
spring.guest.password=guest dubbo.registry.address=zookeeper://127.0.0.1:2181

根据自己的需要修改,包括dubbo-admin用户名密码,当然zk的配置也是少不了的,具体怎么安装zk,启动以及配置,这里就不多说了,

默认的的用户名和密码为:

root
root guest
guest

3.1、访问

localhost:7001

 首页

 service

 provider

consumer

完整代码已上传github 欢迎fork  传送门

springboot整合最新版dubbo以及dubbo-admin的安装的更多相关文章

  1. SpringBoot整合RabbitMQ-整合演示

    本系列是学习SpringBoot整合RabbitMQ的练手,包含服务安装,RabbitMQ整合SpringBoot2.x,消息可靠性投递实现等三篇博客. 学习路径:https://www.imooc. ...

  2. SpringBoot整合RabbitMQ-消息可靠性投递

    本系列是学习SpringBoot整合RabbitMQ的练手,包含服务安装,RabbitMQ整合SpringBoot2.x,消息可靠性投递实现等三篇博客. 学习路径:https://www.imooc. ...

  3. SpringBoot整合RabbitMQ-服务安装

    本系列是学习SpringBoot整合RabbitMQ的练手,包含服务安装,RabbitMQ整合SpringBoot2.x,消息可靠性投递实现等三篇博客. 学习路径:https://www.imooc. ...

  4. springboot整合dubbo+zookeeper最新详细

    引入 最近和小伙伴做一个比赛,处于开发阶段,因为涉及的服务比较多,且服务需要分开部署在不同的服务器上,讨论之后,打算采用分布式来做,之前学习springboot的时候,部分章节涉及到了springbo ...

  5. Springboot 整合 Dubbo/ZooKeeper 详解 SOA 案例

    摘要: 原创出处:www.bysocket.com 泥瓦匠BYSocket 希望转载,保留摘要,谢谢!   “看看星空,会觉得自己很渺小,可能我们在宇宙中从来就是一个偶然.所以,无论什么事情,仔细想一 ...

  6. springboot整合dubbo\zookeeper做注册中心

    springboot整合dubbo发布服务,zookeeper做注册中心.前期的安装zookeeper以及启动zookeeper集群就不说了. dubbo-admin-2.5.4.war:dubbo服 ...

  7. SpringBoot整合dubbo

    Dubbo是阿里巴巴公司开源的一个高性能优秀的服务框架,使得应用可通过高性能的 RPC 实现服务的输出和输入功能,可以和Spring框架无缝集成. 以上介绍来源于百度百科,具体dubbo相关可以自行查 ...

  8. SpringBoot 整合使用dubbo

    这里主要是按照teaey作者的spring-boot-starter-dubbo框架进行一些变化的使用 依赖包: <dependency> <groupId>com.aliba ...

  9. 【转】SpringBoot学习笔记(7) SpringBoot整合Dubbo(使用yml配置)

    http://blog.csdn.net/a67474506/article/details/61640548 Dubbo是什么东西我这里就不详细介绍了,自己可以去谷歌 SpringBoot整合Dub ...

随机推荐

  1. BZOJ4709 Jsoi2011 柠檬【决策单调性+单调栈】

    Description Flute 很喜欢柠檬.它准备了一串用树枝串起来的贝壳,打算用一种魔法把贝壳变成柠檬.贝壳一共有 N (1 ≤ N ≤ 100,000) 只,按顺序串在树枝上.为了方便,我们从 ...

  2. 20179223《Linux内核原理与分析》第十周学习笔记

    课本第17.19和20章内容学习 关于设备驱动和设备管理,Linux主要有四种内核成分 设备类型:在所有Unix系统中为了统一普通设备的操作所采用的分类. 模块:Linux内核中用于按需加载和卸载目标 ...

  3. 在VS2013创建WebService并在IIS中发布和使用

    创建WebService 第一步:打开VS2013,新建空项目,注意选择.NET Framework的版本.这里我选择的是.NET Framework 4 新建好项目后,在项目中添加一个WebServ ...

  4. 异常Failure to transfer org.apache.maven.plugins:maven-surefire-plugin:pom:2.12.4 from http://maven.aliyun.com/nexus/content/groups/public was ...

    错误异常:Failure to transfer org.apache.maven.plugins:maven-surefire-plugin:pom:2.12.4 from http://maven ...

  5. c++深拷贝/浅拷贝

    拷贝构造函数,是一种特殊的构造函数,它由编译器调用来完成一些基于同一类的其他对象的构建及初始化.其唯一的参数(对象的引用)是不可变的(const类型).此函数经常用在函数调用时用户定义类型的值传递及返 ...

  6. Javascript 严格模式下保留关键字

    为了应对未来的版本,以下关键字在严格模式下禁止使用. implements interface let package private protected public static yield 示例 ...

  7. Docker生态会重蹈Hadoop的覆辙吗?

    从网上找到了这篇2016年中旬刷爆朋友圈的文章,没有找到作者和首发出处.两年多过去了,文中分析的很多不确定性都有了结论,里面不少分析思路.观点还是很不错的. Docker的兴起和Hadoop何其相似 ...

  8. hadoop 之Hadoop生态系统

    1.Hadoop生态系统概况 Hadoop是一个能够对大量数据进行分布式处理的软件框架.具有可靠.高效.可伸缩的特点. Hadoop的核心是HDFS和Mapreduce,hadoop2.0还包括YAR ...

  9. volatile浅析

    volatile的意思是不稳定的.易变的,但在多线程中却跟字面意思一毛钱关系没有.作为一个变量修饰符,它主要有两个作用:一个是告诉大家,该变量是一个在多个线程之间均可见的变量:另一个是告诉java虚拟 ...

  10. 【Leetcode 338】 Counting Bits

    问题描述:给出一个非负整数num,对[0, num]范围内每个数都计算它的二进制表示中1的个数 Example:For num = 5 you should return [0,1,1,2,1,2] ...