【问题标题】:File paths for java spark project deployed into Heroku部署到 Heroku 中的 java spark 项目的文件路径
【发布时间】:2017-07-06 06:27:52
【问题描述】:

我已经在 Heroku 上部署了一个 java spark 应用程序,但似乎遇到了以下错误:

2017-02-16T22:17:35.519937+00:00 app[web.1]: java.io.FileNotFoundException: src/main/resources/csvs/webApp/questions/questions.csv (No such file or directory)

我似乎无法找到我的文件。当我在 Eclipse(在 Windows 上)本地运行项目时,一切正常。我需要更改哪些文件路径才能让应用程序在运行时找到文件。本地工作代码示例代码:

String directory = "src/main/resources/csvs/webApp/questions/";
BufferedReader questions = null;
String line;
ArrayList<String> questionList = new ArrayList<String>();

try {
    questions = new BufferedReader(new FileReader(directory + "questions.csv"));

    while ((line = questions.readLine()) != null) {
        if(!(line.equals("Question"))) {
            questionList.add(line);   
        }
    }

} catch (FileNotFoundException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
}

感谢您的帮助。

【问题讨论】:

  • 你使用的是什么部署方式,git push 还是heroku deploy:jar?你能通过运行heroku run ls src/main/resources/csvs/webApp/questions/questions.csv来确认文件存在吗?
  • 我正在使用 heroku deploy,当我运行 heroku run ls src/main/resources/csvs/webApp/questions/questions.csv 时出现不存在错误。
  • heroku deploy 不会上传您的src/ 目录。

标签: java eclipse heroku spark-framework


【解决方案1】:

heroku deploy:warheroku deploy:jar 命令默认不会上传你的src/ 目录(只会分别上传你的WAR 或JAR 文件)。

您可以将--includes src 选项添加到heroku deploy:* 命令。

【讨论】:

    猜你喜欢
    • 2019-08-21
    • 2022-01-17
    • 1970-01-01
    • 2019-10-18
    • 2021-01-03
    • 2019-01-03
    • 2016-01-11
    • 2020-10-24
    • 2013-07-11
    相关资源
    最近更新 更多