windows 搭建dubbo微服务

https://www.cnblogs.com/lionsblog/p/7767379.html

https://blog.csdn.net/linuu/article/details/53758854

链接:https://www.jianshu.com/p/9be765a43f19

注册中心的安装

首先先安装一个zookeeper,至于zookeeper的安装这里就不多做介绍了,可自行查找。

监控中心安装

进入dubbo-simple/dubbo-monitor-simple/target目录,可以看到dubbo-monitor-simple-2.4.10-assembly.tar.gz文件。

tar -zxvf dubbo-monitor-simple-2.4.10-assembly.tar.gz

解压后进入目录,

vim conf/dubbo.properties

修改注册中心的配置,注释掉广播地址,改为zookeeper作为注册中心,

#dubbo.registry.address=multicast://224.5.6.7:1234
dubbo.registry.address=zookeeper://127.0.0.1:2181

其它参数如有需要可自行修改。(注意:如果是本机测试,将monitor和admin都撞倒一台机器上时,可以将dubbo.jetty.port=8083)
执行:

sh bin/start.sh

可启动mointor。访问地址:http://127.0.0.1:8083 (默认为8080,8083是修改后的值)

管理员控制台安装

进入源码编译目录,进入到dubbo-admin/target,可以看到dubbo-admin-2.4.10这个文件夹。这是web项目,需要运行在web容器下,我这里是运行到tomcat下。这个默认使用zookeeper作为注册中心的,不过配置的本机地址,如果需要修改为其他ip,只需修改WEB-INF/dubbo.properties下的配置地址即可。

扫描二维码关注公众号,回复: 26149 查看本文章
dubbo.registry.address=zookeeper://127.0.0.1:2181

启动tomcat即可。访问地址:http://127.0.0.1:8080/dubbo-admin-2.4.10 (根据自己的tomcat配置来访问)

运行provider

进入dubbo-demo/dubbo-demo-provider/target,

tar -zxvf dubbo-demo-provider-2.4.10-assembly.tar.gz

修改注册中心的配置地址为zookeeper,如下:

#dubbo.registry.address=multicast://224.5.6.7:1234
dubbo.registry.address=zookeeper://127.0.0.1:2181

执行

sh bin/start.sh

来启动provider服务。

运行consumer

进入dubbo-demo/dubbo-demo-consumer/target,

tar -zxvf dubbo-demo-consumer-2.4.10-assembly.tar.gz

修改注册中心的配置地址为zookeeper,如下:

#dubbo.registry.address=multicast://224.5.6.7:1234
dubbo.registry.address=zookeeper://127.0.0.1:2181

执行

sh bin/start.sh

来启动consumer服务。



作者:kevinp
链接:https://www.jianshu.com/p/9be765a43f19
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。




------------------------------------------------------------------------------------------------------------------------






二:详细步骤实践



首先从wget https://github.com/alibaba/dubbo/archive/master.zip下载最新源码,目前最新版本为2.5.4-SNAPSHOT

解压文件  
cd dubbo  
mvn clean install -Dmaven.test.skip  

报错:Non-resolvable parent POM: Could not transfer artifact com.alibaba:opensesame:pom:2.0 from/to opensesame.releases (http://code.alibabatech.com/mvn/releases)

README上已经说明了需要本地安装“由于开源站点因为安全问题被下掉,如果编译时出现找不到opensesame依赖情况的,请先手动下载https://github.com/alibaba/opensesame”,那就自己安装吧
下载opensesame,之后进入opensesame目录,执行:mvn install 等待success吧

再次执行:

mvn clean install -Dmaven.test.skip

又是一堆的错误啊:
[ERROR] Failed to execute goal on project dubbo-common: Could not resolve dependencies for project com.alibaba:dubbo-common:jar:2.5.4-SNAPSHOT: Failed to collect dependencies for [org.slf4j:slf4j-api:jar:1.6.2 (provided), commons-logging:commons-logging-api:jar:1.1 (provided), log4j:log4j:jar:1.2.16 (compile), org.javassist:javassist:jar:3.15.0-GA (compile), com.alibaba:hessian-lite:jar:3.2.1-fixed-2 (compile), com.alibaba:fastjson:jar:1.1.8 (provided), org.jvnet.sorcerer:sorcerer-javac:jar:0.8 (provided), cglib:cglib-nodep:jar:2.2 (test), junit:junit:jar:4.10 (test), org.easymock:easymock:jar:3.0 (test), org.easymock:easymockclassextension:jar:3.0 (test), com.googlecode.jmockit:jmockit:jar:0.999.8 (test)]: Failed to read artifact descriptor for com.alibaba:hessian-lite:jar:3.2.1-fixed-2: Could not transfer artifact com.alibaba:hessian-lite:pom:3.2.1-fixed-2 from/to opensesame.releases (http://code.alibabatech.com/mvn/releases): Connection to http://code.alibabatech.com refused: Connection refused -> [Help 1]

很多文件从阿里的仓库中都找不到了,到处找解决方法啊。在这个贴子上有提到了更改配置仓库:https://github.com/alibaba/dubbo/issues/22

<mirror>
<id>kafeitu</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://maven.kafeitu.me/nexus/content/repositories/public</url>
</mirror>
<mirror>
<id>ibiblio.org</id>
<name>ibiblio Mirror of http://repo1.maven.org/maven2/</name>
<url>http://mirrors.ibiblio.org/pub/mirrors/maven2</url>
<mirrorOf>*</mirrorOf>
</mirror>
<mirror>
<id>lvu.cn</id>
<name>lvu.cn</name>
<url>http://lvu.cn/nexus/content/groups/public</url>
<mirrorOf>*</mirrorOf>
</mirror>

将上面的配置加入maven配置文件setting.xml中

再次执行:

mvn clean install -Dmaven.test.skip  

依然报错:
[ERROR] Failed to execute goal on project dubbo-common: Could not resolve dependencies for project com.alibaba:dubbo-common:jar:2.5.4-SNAPSHOT: Failed to collect dependencies for [org.slf4j:slf4j-api:jar:1.6.2 (provided), commons-logging:commons-logging-api:jar:1.1 (provided), log4j:log4j:jar:1.2.16 (compile), org.javassist:javassist:jar:3.15.0-GA (compile), com.alibaba:hessian-lite:jar:3.2.1-fixed-2 (compile), com.alibaba:fastjson:jar:1.1.8 (provided), org.jvnet.sorcerer:sorcerer-javac:jar:0.8 (provided), cglib:cglib-nodep:jar:2.2 (test), junit:junit:jar:4.10 (test), org.easymock:easymock:jar:3.0 (test), org.easymock:easymockclassextension:jar:3.0 (test), com.googlecode.jmockit:jmockit:jar:0.999.8 (test)]: Failed to read artifact descriptor for com.alibaba:hessian-lite:jar:3.2.1-fixed-2: Could not find artifact com.alibaba:opensesame:pom:1.0 in ibiblio.org (http://mirrors.ibiblio.org/pub/mirrors/maven2) -> [Help 1]

在这个错误文件中发现了Could not find artifact com.alibaba:opensesame:pom:1.0,不是2.0么,怎么1.0也要。既然需要,那咱就给呗。
还记得上面自己下载的opensesame源码不,修改下面的pom.xml,将 2.0中2.0修改为1.0
执行 mvn install 等待success吧

再次执行:

mvn clean install -Dmaven.test.skip

依然出错
[ERROR] Failed to execute goal on project dubbo-common: Could not resolve dependencies for project com.alibaba:dubbo-common:jar:2.5.4-SNAPSHOT: Could not find artifact com.alibaba:fastjson:jar:1.1.8 in ibiblio.org (http://mirrors.ibiblio.org/pub/mirrors/maven2) -> [Help 1]

不过看到那么多的错误一下便少了,心理还是暗爽的,哈哈。
到http://maven.kafeitu.me/nexus/content/repositories/public/这个上面看了下fastjson可用版本有1.1.39,于是修改pom.xml,找到 1.1.8,将1.1.8修改为1.1.39

再次执行:

mvn clean install -Dmaven.test.skip  


三:错误收集

 

dubbo启动失败 Could not load com.alibaba.dubbo.common.utils.NetUtils


  1. ERROR context.ContextLoader - Context initialization failed  
  2. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'uriBrokerService': Cannot create inner bean '(inner bean)' of type [com.alibaba.citrus.service.uribroker.impl.URIBrokerServiceImpl$URIBrokerInfo]

jdk1.8的兼容性问题,修改

1、webx的依赖改为3.1.6版

[html]  view plain  copy
  1. <dependency>  
  2.     <groupId>com.alibaba.citrus</groupId>  
  3.     <artifactId>citrus-webx-all</artifactId>  
  4.     <version>3.1.6</version>  
  5. </dependency>  
2、添加velocity的依赖,我用了1.7
[html]  view plain  copy
  1. <dependency>  
  2.     <groupId>org.apache.velocity</groupId>  
  3.     <artifactId>velocity</artifactId>  
  4.     <version>1.7</version>  
  5. </dependency>  
3、对依赖项dubbo添加exclusion,避免引入旧spring

[html]  view plain  copy
  1. <dependency>  
  2.     <groupId>com.alibaba</groupId>  
  3.     <artifactId>dubbo</artifactId>  
  4.     <version>${project.parent.version}</version>  
  5.     <exclusions>  
  6.         <exclusion>  
  7.             <groupId>org.springframework</groupId>  
  8.             <artifactId>spring</artifactId>  
  9.         </exclusion>  
  10.     </exclusions>  
  11. </dependency>  
4、webx已有spring 3以上的依赖,因此注释掉dubbo-admin里面的spring依赖
[html]  view plain  copy
  1. <!--<dependency>-->  
  2.     <!--<groupId>org.springframework</groupId>-->  
  3.     <!--<artifactId>spring</artifactId>-->  
  4. <!--</dependency>-->  

逐个项目编译,重新打包,部署。

确定war包解压后,lib目录没有spring3以下的包

D:\tools\incubator-dubbo-dubbo-2.4.10\dubbo-admin>D:\apache-maven-3.5.3\bin\mvn clean package -Dmaven.test.skip=true











猜你喜欢

转载自blog.csdn.net/chinewwen/article/details/79965109