发表于: 2017-11-13 23:43:51

1 958



今天完成的事情:

1. zookeeper+ dubbo 的单机模式

2. dubbo的war打包成功 

3. 把service 打成了jar包


明天计划的事情

1. 完成分布式布置

2. 上线服务器


遇到的问题:

1. 关于dubbo的打包问题

http://dubbo.io/

下载2.5.7 版本,这个版本契合jdk1.8,其他的不行。

在这个网站上下载的zip整体打开进行编译,不要只打开dubbo-admin模块 , 否则pom报

<parent>
   <groupId>com.alibaba</groupId>
   <artifactId>dubbo-parent</artifactId>
   <version>2.5.7</version>
</parent>

有问题

整个项目的pom从

<!--<groupId>org.apache.maven.plugins</groupId>-->
<!--<artifactId>maven-surefire-plugin</artifactId>-->

到 

<!--<name>onerror</name>-->
<!--<value>${onerror}</value>-->

注释掉,否者编译不通过

并且配置备用maven仓库:

<repositories>
   <repository>
       <id>json</id>
       <name>json</name>
       <url>http://maven.jahia.org/maven2/</url>
   </repository>
   <repository>
       <id>maven2</id>
       <name>maven2</name>
       <url> http://central.maven.org/maven2/</url>
   </repository>

   <repository>
       <id>opensesame</id>
       <name>Alibaba OpenSource Repsoitory</name>
       <url>http://code.alibabatech.com/mvn/releases/</url>
       <snapshots>
           <enabled>false</enabled>
       </snapshots>
   </repository>

千万!千万!千万!不能相信网上的在maven的setting.xml配置不知道哪里的镜像仓库的建议,里面的不少配置文件的标签上下文不对应,🙂(MMP)!


如果你不小心配置了,并下载了,就需要在不断的报错了删除那些包,从新从上面配置的中央仓库里下载。



2. IDEA里启动没有问题,JAR启动报错:

Caused by: org.xml.sax.SAXParseException; lineNumber: 14; columnNumber: 50; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'dubbo:application'.

百度说是少dubbo.xsd文件,但是我配置上后还是报错,正确的方式是因为打包出错,应在pom里配置:

<!-- 打包jar文件时,配置manifest文件,加入lib包的jar依赖 -->
<plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-jar-plugin</artifactId>
 <configuration>
   <classesDirectory>target/classes/</classesDirectory>
   <archive>
     <manifest>
       <!-- 主函数的入口 -->
       <mainClass>jnshu.taskeight.main.RMIService</mainClass>
       <!-- 打包时 MANIFEST.MF文件不记录的时间戳版本 -->
       <useUniqueVersions>false</useUniqueVersions>
       <addClasspath>true</addClasspath>
       <classpathPrefix>lib/</classpathPrefix>
     </manifest>
     <manifestEntries>
       <Class-Path>.</Class-Path>
     </manifestEntries>
   </archive>
 </configuration>
</plugin>
<plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-dependency-plugin</artifactId>
 <executions>
   <execution>
     <id>copy-dependencies</id>
     <phase>package</phase>
     <goals>
       <goal>copy-dependencies</goal>
     </goals>
     <configuration>
       <type>jar</type>
       <includeTypes>jar</includeTypes>
       <outputDirectory>
         ${project.build.directory}/lib
</outputDirectory>
     </configuration>
   </execution>
 </executions>
</plugin>

mvn package打包后,如果要移动的话一定要把同级目录下的lib文件夹移走。



收获:

1. zookeeper+ dubbo 的单机模式

开启的service

接口名称:

自行配制的应用名:


关键在于对整个dubbo项目的打包,每个模块下都生成一个war,我们需要的是dubbo-admain下的

将war放到tomcat下,解压后打开WEB-INF修改dubbo.properties

这是两个账号和密码

打开网页后输入账户密码登陆对其进行调整。


在service里的配置:

<context:component-scan base-package="jnshu.taskeight"/>
<!-- 提供方应用信息,用于计算依赖关系 -->
<dubbo:application name="jnshu-service-app"/>
<!-- 暴露服务地址,注册中心地址 -->
<dubbo:registry address="zookeeper://127.0.0.1:2181" check="false" subscribe="false" register=""/>
<!-- dubbo协议在20880端口暴露服务 -->
<dubbo:protocol name="dubbo" port="20880" />
<dubbo:service interface="jnshu.taskeight.service.StudentService" ref="studentServiceImpl" timeout="1200000"/>
<dubbo:service interface="jnshu.taskeight.service.CountNumberService" ref="countNumberServiceImpl" timeout="1200000"/>
<dubbo:service interface="jnshu.taskeight.service.ProfessionService" ref="professionServiceImpl" timeout="1200000"/>

红字为超时时间,如果不设置默认为5000,但是第一次连数据库获知缓存崩了就有可能超出时间


client配置:


<context:component-scan base-package="jnshu.taskeight"/>
<!-- 消费方应用名,用于计算依赖关系,不是匹配条件,不要与提供方一样 -->
<dubbo:application name="jnshu-client-app"  />
<!-- 注册中心,发现服务的地址 -->
<dubbo:registry address="zookeeper://127.0.0.1:2181" check="false"/>
<!-- 生成远程服务代理,可以和本地bean一样使用demoService -->
<dubbo:reference id="studentService" interface="jnshu.taskeight.service.StudentService" />
<dubbo:reference id="professionService" interface="jnshu.taskeight.service.ProfessionService" />
<dubbo:reference id="countNumberService" interface="jnshu.taskeight.service.CountNumberService" />

然后就可以在dubbo提供的管理页面里管理相关内容了。




2. 把dubbo这个阿里已经闭源的项目由源码调试编译成功,真的是好费劲,顶级父包

dubbo-parent

的缺失,需要让你把整个项目进行编译处理,更改适应的jdk,由1.7到1.8




进度: 

         任务开始时间:11.09

         预计完成时间:11.12

         第一次延期到11.13

         第二次延期到11.14

         是否有延期风险:有,今天的dubbo的包重新编译很多报错,耽误时间

禅道:http://task.ptteng.com/zentao/project-task-264.htm




返回列表 返回列表
评论

    分享到