在Cloud Foundry上运行应用程序时找不到文件

发布于 2025-01-24 06:01:43 字数 308 浏览 3 评论 0原文

在本地运行应用程序时,它可以正常运行。但是,在我用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

趁年轻赶紧闹 2025-01-31 06:01:43

当您的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 the HOME environment variable. When your application runs, the HOME env variable points to /home/vcap/app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文