代码如下:
public static void main(String[] args) throws Exception {
Configuration conf = HBaseConfiguration.create();
conf.set("hbase.zookeeper.property.clientPort", "2181");
conf.set("hbase.zookeeper.quorum", "10.2.1.12");
Iterator> i = conf.iterator();
while (i.hasNext()) {
Map.Entry entry = i.next();
System.out.println(entry.getKey() + ":" + entry.getValue());
}
//Connection connection = ConnectionFactory.createConnection(conf);
//connection.getTable(TableName.valueOf("HBASE_TABLENAME_TRACELOG"));
//System.out.println("----------------------------");
}
从而省去了从hbase-site.xml读取配置的麻烦(运维只需要维护一份properties即可)