在java代码中找到hive-site.xml的位置 [英] Find the location of hive-site.xml in java code

查看:1313
本文介绍了在java代码中找到hive-site.xml的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的java程序中传递hive-site.xml文件的位置。



自动找到这个文件的位置的最佳方法是什么在java代码中?



我不想将路径硬编码到 /etc/hive/conf/hive-site.xml for cloudera distibution

解决方案

默认情况下,Hadoop Configuration 构造函数在 CLASSPATH 中搜索目录中的blahblah-site.xml配置文件。如果它没有找到它们,那么它将恢复为硬编码的默认值,不会有任何警告(!)。因此,请确保CLASSPATH包含正面的合适目录,例如 / etc / hadoop / conf /:/ etc / hive / conf /:/ etc / tez / conf /:...



然后,您必须在Java代码中执行的唯一一件事是检查是否使用硬编码默认值设置了其他关键属性(并且如果不是该属性,则会引发)案件)。


I want to pass the location of hive-site.xml file in my java program.

What is the best way to find out the location of this file automatically in java code?

I do not want to hard code the path to /etc/hive/conf/hive-site.xml for cloudera distibution

解决方案

By default the Hadoop Configuration constructors search for "blahblah-site.xml" config files in directories present in CLASSPATH. If it doesn't find them, then it reverts to hard-coded "default" values, without any warning (!).

So make sure that the CLASSPATH contains the appropriate directories on the front, e.g. /etc/hadoop/conf/:/etc/hive/conf/:/etc/tez/conf/:...

Then the only thing you have to do in your Java code is to check that critical properties are set up with something else that hard-coded defaults (and raise a PleaseSetupProperClasspathYouSuckerException if it's not the case).

这篇关于在java代码中找到hive-site.xml的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆