环境依赖
- JDK: version 6 or higher
- Maven: version 3 or higher
注册中心搭建
- zookeeper机器搭建
详见zookeeper搭建
dubbo监控中心搭建
dubbo-admin 本地编译打包
dubbo的所有源码可在https://github.com/alibaba/dubbo上下载。下好之后解压
dubbo-admin部署
- 安装
将 dubbo-admin-2.5.4-SNAPSHOT.war 拷入 tomcat webapps中 - 配置
修改tomcat的端口8088,修改方法如下,打到conf下的文件 server.xml,因为zookeeper会用到8080的端口,所以为了不冲突,把Tomcat的端口改一下。
服务搭建
- maven 依赖
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.5.5</version>
</dependency>
- 配置
import com.alibaba.dubbo.config.*;
import com.alibaba.dubbo.config.spring.AnnotationBean;
import com.alibaba.dubbo.rpc.Invoker;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* Created by dream on 2017/5/9.
*/
@Configuration
@ConditionalOnClass(Invoker.class)
public class DubboConfiguration {
@Value("${dubbo.application.name}")
private String applicationName;
@Value(