【问题标题】:How to retrieve files from cloud foundry?如何从 Cloud Foundry 中检索文件?
【发布时间】:2016-10-07 15:27:18
【问题描述】:

我目前有一个 Spring Boot Web 应用程序。每次刷新 Web 应用程序时,应用程序都会写入文件。在本地,我可以看到根路径目录中的文件。但是当我将我的 .jar 文件上传到 Cloud Foundry 时,我将如何获得正在写入的那些文件?

脚本 sn-p 写入文件

try{
Date date = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
File file = new File(dateFormat.format(date) + "data.txt");
BufferedWriter out = new BufferedWriter(new FileWriter(file));
out.write("Some Data is being written");
out.close;
} 

我可以在我的根文件夹中找到 data.txt。但是,在将应用程序打包到 jar 并将其推送到 Cloud Foundry 之后,如何获取这些文件。

参照推送命令

 -cf push testapp -p target/webapp.jar

【问题讨论】:

  • 你对你的申请做了什么?你有什么尝试?您是否查看过他们的快速入门并尝试在那里应用您自己的代码?
  • @AshFrench 是的,我看过他们的指南并做了很多。但是当我运行 jar 文件时(在我清理打包之后),我可以在没有错误的情况下实现我的。
  • 好的,我现在的java文件基本上输出了一些数据,比如cpu空间,内存空闲%等。我用spring创建了一个带有thymeleaf及其功能的网页。我正在尝试实现我的 java 文件,它将 cpu 空间上的数据获取到我的 html 页面中。 。但是当我运行程序时,我无法弄清楚如何放入我的java文件而不会出错。我坚信我需要添加一些弹簧注释。但我的问题是什么。

标签: java spring-boot cloud-foundry


【解决方案1】:
【解决方案2】:

试试这个:

cf ssh-code 然后:

scp -P 2222 -o User=cf:<APP_GUID>/0 ssh.<system domain>:/<path>/<file name> <LOCAL_FILE_SYS>

谢谢,

陈丹

【讨论】:

    猜你喜欢
    • 2018-07-08
    • 1970-01-01
    • 2021-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-24
    • 1970-01-01
    相关资源
    最近更新 更多