在Cloud Foundry上运行应用程序时找不到文件
在本地运行应用程序时,它可以正常运行。但是,在我用maven构建一个罐子并将其推到云铸造厂后,它无法通过本地的绝对文件路径找到KRB5.Keytab文件 KRB5.Keytab的路径正在我的application.yml文件中设置。例如 keytab: 钥匙:krb5.keytab 文件:c:\ users \ documents \ workspace \ myproject \ myproject \ kafkatool \ krb5.keytab
我需要如何更改krb5.keytab的文件路径,因此当它在Cloud Foundry上运行时,该应用程序仍然可以找到KeyTab?
When running the app locally, it works. However, after I build a jar with maven and push it to cloud foundry, it cannot find the krb5.keytab file through the local absolute file path
The krb5.keytab's path are setting in my application.yml file. e.g
keytab:
key: krb5.keytab
file: C:\Users\Documents\WorkSpace\MyProject\kafkatool\krb5.keytab
How do I need to change the file path of krb5.keytab so when it's running on cloud foundry the app can still find the keytab?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您的Java应用程序在CloudFoundry上运行时,它将在远程Linux容器中运行。它无法访问您的本地文件系统,您引用的任何文件都需要在Linux容器的文件系统中,因此无
c:\
Windows式路径将起作用。您的应用程序在CF上运行时,生活在
/home/vcap/app
Directory中(在/app
中也有一个符号链接,指向/home/home/vcap /app
,可以在需要的情况下使用)。此外,您的应用程序将从
/home/vcap/app
目录中执行,因此当前的工作目录将为/home/vcap/vcap/app
。因此,如果您需要引用文件,则可以相对于
/home/vcap/app
目录引用它们,也可以将/home/vcap/app
to Prefix前缀路径并使用文件的完整路径。如果您不喜欢硬编码
/home/home/vcap/app
进入应用程序的想法,则可以通过查看home
环境变量来动态获取此目录。运行应用程序时,HOME
Env变量指向/HOME/VCAP/APP
。When your Java application runs on CloudFoundry, it's running in a remote Linux container. It does not have access to your local file system and any files you reference need to be within the Linux container's filesystem, thus no
c:\
Windows-style paths are going to work.Your application, when running on CF, lives in the
/home/vcap/app
directory (there's also a symlink at/app
which points to/home/vcap/app
that you can use if you want).In addition, your application will be executed out of the
/home/vcap/app
directory so the current working directory will be/home/vcap/app
.Thus, if you need to reference files you can either reference them relative to the
/home/vcap/app
directory or you can prefix the/home/vcap/app
to all paths and use a full path to the file.If you don't like the idea of hard-coding
/home/vcap/app
into your application, you can fetch this directory dynamically by looking at theHOME
environment variable. When your application runs, theHOME
env variable points to/home/vcap/app
.