Ошибка шаблона thymeleaf на продакшене
Как дать доступ к папке с шаблонами?. Ведь очевидно, что шаблон существует.
Лог ошибки
2021-02-27 16:15:41.834 ERROR 100721 --- [nio-5000-exec-1] org.thymeleaf.TemplateEngine : [THYMELEAF][http-nio-5000-exec-1] Exception processing template "index": Error resolving template [/parts/html/search], template might not exist or might not be accessible by any of the configured Template Resolvers (template: "index" - line 4, col 14)
html
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" th:replace="~{fragments/layout :: layout (~{::body},'index')}">
<body>
<div th:replace="~{/parts/html/search}"></div>
Шаблон располагается по пути: /path/to/project/src/main/resources/templates/parts/html/search.html
Ответы (1 шт):
Автор решения: LogIN
→ Ссылка
@Bean
public TemplateResolver templateResolver() {
TemplateResolver templateResolver = new ClassLoaderTemplateResolver();
templateResolver.setPrefix("templates/");
templateResolver.setCacheable(false);
templateResolver.setSuffix(".html");
templateResolver.setTemplateMode("HTML5");
return templateResolver;
}
https://stackoverflow.com/a/40167690
Это помогло. Если путь к ресурсам такой же как у меня.