Creating Configuration
Function
HBase obtain configuration items by using the login method. The configuration items include user login information and security authentication information.
Example Codes
The following code snippet belongs to the init method in the TestMain class of the com.huawei.bigdata.hbase.examples package.
private static void init() throws IOException { // Default load from conf directory conf = HBaseConfiguration.create(); //In Windows environment String userdir = TestMain.class.getClassLoader().getResource("conf").getPath() + File.separator;[1] //In Linux environment //String userdir = System.getProperty("user.dir") + File.separator + "conf" + File.separator; conf.addResource(new Path(userdir + "core-site.xml"), false); conf.addResource(new Path(userdir + "hdfs-site.xml"), false); conf.addResource(new Path(userdir + "hbase-site.xml"), false); }
[1]The value of userdir is the path of the conf directory in the resource path after compilation. Place the core-site.xml, hdfs-site.xml, and hbase-site.xml configuration files to the src/main/resources/conf directory.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot