部署到Heroku的Spring Boot应用程序没有找到它的'百日咳视图

Vác*_*lav 3 java spring heroku thymeleaf spring-boot

我的Spring Boot应用程序运行完美,localhost但是当我将它部署到Heroku时,我的应用程序的控制器停止查看通常位于/ templates /目录的视图.为什么会这样?我怎样才能确定heroku实际上传和编译我的观点?如果是的话,我应该更改@Controller类的@RequestMapping的实际值,以便在它们位于heroku时可以访问它们吗?

你可以在这里找到我的整个工作webapp:https://github.com/slavicketernity/testik56

这是我上传的和runnung应用程序:https://testik56app.herokuapp.com/login

kon*_*kit 5

在我的情况下,它是由控制器的方法返回的字符串的开头斜杠的错误与模板位置.

我改变了控制器方法返回的String之后

@RequestMapping(value = "/orders/{orderId}/create_entry")
String create(@PathVariable String orderId) {
    return "/order_entries/create";
}
Run Code Online (Sandbox Code Playgroud)

@RequestMapping(value = "/orders/{orderId}/create_entry")
String create(@PathVariable String orderId) {
    return "order_entries/create";
}
Run Code Online (Sandbox Code Playgroud)

然后它就开始起作用了.


小智 1

您是否将此应用程序部署为 .jar?我看到一些基础设施要求您将应用程序部署为 .war 以提供对网页目录的访问。

如果这是问题,您可以通过 gradle 应用 war 插件。 https://docs.gradle.org/current/userguide/war_plugin.html