gpt4 book ai didi

java - Spark +速度: Unable to load resources (ResourceNotFoundException)

转载 作者:行者123 更新时间:2023-11-30 06:32:30 25 4
gpt4 key购买 nike

我目前正在使用 Spark 并尝试通过 Velocity 使用基于 documentation 的模板.

但是我遇到了一些错误,任何人都可以提供有关如何成功加载模板的指导吗?

Aug 22, 2017 2:26:43 PM org.apache.velocity.runtime.log.JdkLogChute log
SEVERE: ResourceManager : unable to find resource 'www/templates/template.html' in any resource loader.
[qtp1951434327-14] ERROR spark.http.matching.GeneralError -
org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'www/templates/template.html'
public class Minimal {

public static void main(String[] args) {
get("test", (req, res) -> {
Map<String, Object> model = new HashMap<>();
return render(model, "www/templates/template.html");
});
}

public static String render(Map<String, Object> model, String path) {
return new VelocityTemplateEngine().render(new ModelAndView(model, path));
}
}

我已经阅读并尝试了许多 Stack Overflow 问题的解决方案,但似乎没有一个对我的情况有帮助。

一些解决方案包括设置属性,或具有特定的项目结构等。尽管看起来这些都没有解决问题,并导致相同的异常。

最佳答案

您需要将模板放入资源文件夹中。请参阅example在spark中,可以看到maven的pom资源定义。

关于java - Spark +速度: Unable to load resources (ResourceNotFoundException),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45819253/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com