【问题标题】:Heroku. Java. Unable to find resource. My deployed app can't find file in resource folder赫罗库。爪哇。找不到资源。我部署的应用程序在资源文件夹中找不到文件
【发布时间】:2022-08-21 01:55:05
【问题描述】:

配置文件:

// import org.apache.velocity.app.VelocityEngine;
@Bean
public VelocityEngine velocityEngine() {
    final VelocityEngine velocityEngine = new VelocityEngine();

    velocityEngine.setProperty(\"resource.loader\", \"class\");
    velocityEngine.setProperty(\"class.resource.loader.class\", \"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader\");

    return velocityEngine;
}

本地一切都很好,但是当我将我的应用程序部署到 Heroku 时 我抓住了那个例外:

velocityEngine.getTemplate(\"./templates/template_1.html\");

例外:

ResourceNotFoundException
Unable to find resource \'./templates/template_1.html\'

    标签: java spring email heroku velocity


    【解决方案1】:

    您需要使用velocityEngine.getTemplate("templates/template_1.html"),因为像./templates/template_1.html 这样的基于绝对/文件系统的路径在应用程序打包到jar 文件或docker 映像后将不存在。您可以在github 中找到示例应用程序

    【讨论】:

      猜你喜欢
      • 2013-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-08
      • 1970-01-01
      • 2019-05-18
      • 2017-10-17
      • 1970-01-01
      相关资源
      最近更新 更多