zoukankan      html  css  js  c++  java
  • 搭建Zookeepeer源码工程

    一、搭建ant环境

          1、下载ant&将ant解压至安装目录

          http://ant.apache.org/bindownload.cgi

          2、配置环境变量

          ANT_HOME:配置ant的安装目录,如C:Program FilesApacheapache-ant-1.10.1

          PAT中加:C:Program FilesApacheapache-ant-1.10.1in

          CLASSPATH中加:C:Program FilesApacheapache-ant-1.10.1lib

          3、验证ant

          

          注:第一个命令报错,是因为ant编译是从build.xml开始。

    二、编译Zookeepeer源码

          1、下载zookeepeer源码

          https://github.com/apache/zookeeper

          2、使用ant eclipse命令编译zookeepeer

          注意,一定要在zookeepeer的源码文件夹的根目录。

           

          这里就会一直下载依赖包,然后编译,。。。,直至成功,时间比较久。

          

          3、编译错误解决

          错误1:编译完成后,用IDE打开(这里我用的是Eclipse,机器上装的JDK为1.8),编译错误,显示Java compiler level does not match 和 '<>' operator is not allowed for source level below 1.7错误,说明我们的JDK版本设置的有问题,我们需要将这个工程的JDK调整为1.7。

          调整方法为:右键项目--属性--勾选Enable project  specific  settings--Compiler compliance level--选择1.7--OK

          错误2:org.apache.zookeeper.Version报错,org.apache.zookeeper.version.Info这个接口找不到。

          这个接口可以通过运行org.apache.zookeeper.version.util.VerGen的Main方法来生成这个文件,方法需要传递3个参数,这里我直接固定了参数,如下所示:      

     1 public static void main(String[] args2) {
     2         String[] args =new String[]{"1.0.0"," ",""};
     3         System.out.println("args's length:"+args.length);
     4         if (args.length != 3)
     5             printUsage();
     6         try {
     7             Version version = parseVersionString(args[0]);
     8             if (version == null) {
     9                 System.err.println(
    10                         "Invalid version number format, must be "x.y.z(-.*)?"");
    11                 System.exit(1);
    12             }
    13             String rev = args[1];
    14             if (rev == null || rev.trim().isEmpty()) {
    15                 rev = "-1";
    16             } else {
    17                 rev = rev.trim();
    18             }
    19             generateFile(new File("."), version, "", args[2]);
    20         } catch (NumberFormatException e) {
    21             System.err.println(
    22                     "All version-related parameters must be valid integers!");
    23             throw e;
    24         }
    25     }

          最后生成这个org.apache.zookeeper.version.Info.java这个文件,整个Zookeepeer工程编译成功。

          PS:对于Info.java接口文件的生成,你也可以直接观察一下源码,直接新建这个接口文件,然后把相应的字段和值补全就好了。

    参考文档

          https://www.cnblogs.com/ivictor/p/4994112.html

          http://blog.csdn.net/zhangyuan19880606/article/details/51508294

          http://blog.csdn.net/puma_dong/article/details/52000283

  • 相关阅读:
    linux内核同步机制相关收集
    【转载】关于终端和控制台的一些解释
    【转】linux内核调试方法总结
    misc汇总
    关于proc的介绍,比较详细
    linux内核启动流程分析
    linux通用中断子系统介绍
    ftrace在mips上的验证
    线程死锁demo
    BeanFactory与FactoryBean
  • 原文地址:https://www.cnblogs.com/gudi/p/8068610.html
Copyright © 2011-2022 走看看