Configuration conf = new Configuration();
conf.set("hadoop.security.authentication", "kerberos");
UserGroupInformation.setConfiguration(conf);
URL file = this.getClass().getClassLoader().getResource("file.keytab");
UserGroupInformation.loginUserFromKeytab("xyzUser", file.getPath());
我的 keytab 文件保存在根文件夹中,我已将其作为资源标签添加到我的 pom.xml 中。下面是我正在测试我的 jar 文件的命令:
java -jar myjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar