本文介绍了当部署在Pivotal Cloud Foundry平台上时,Spring Boot微服务无法通过Kerberos身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们开发了一个Spring Boot应用程序,可以从HDP 2.5上的Hbase查询数据.
当我们在本地Windows机器上运行该应用程序时,该应用程序运行良好,因为它能够找到jaas.conf& krb5.conf文件已保存在应用程序的资源文件夹下,我们已在代码中将它们作为系统属性提供,例如
System.setProperties("javax.security.auth.useSubjectCredsOnly","false");System.setProperty("java.security.krb5.conf","D:\\host\\workspace\\projectname\\src\\main\\resources\\krb5.conf");

但是,当我们在PCF中部署时,它无法读取设置为系统属性的那些文件.

问题
在PCF中设置环境变量的方法是什么?
我们如何将文件放置在PCF中,以便它们可用于应用程序的类路径?

We have developed a Spring Boot Application to query data from Hbase on HDP 2.5.
The application works fine when we run it on our local windows machines as it is able to find the jaas.conf & krb5.conf file which have been kept under resources folder of the application and we have provided them as system properties in our code as e.g.
System.setProperties("javax.security.auth.useSubjectCredsOnly","false");System.setProperty("java.security.krb5.conf","D:\\host\\workspace\\projectname\\src\\main\\resources\\krb5.conf");

However when we deploy in PCF it is unable to read those file which are set as system properties.

Question
What is the way to set environment variables in PCF ?
How do we place files in PCF so that they are available to the classpath of an application ?

推荐答案

您可以在部署清单文件中指定环境变量.这是详细信息.

You can specify an environment variable in your deployment manifest file.Here are the details.

这是假设您的jar文件与krb5.conf文件打包在一起.

This is assuming your jar file was packaged with krb5.conf file.

另一个选项是使用Config Server.这是有关 Spring Cloud Config

The other option is to use Config Server. Here is an introduction on Spring Cloud Config

这篇关于当部署在Pivotal Cloud Foundry平台上时,Spring Boot微服务无法通过Kerberos身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 03:03