Heroku에 내 Spring App을 성공적으로 전개했으나, 실제로 작동중인 응용 프로그램을 테스트하려고 시도 할 때 Error resolving template "/fragments/head.html", template might not exist or might not be accessible by any of the configured Template Resolvers (home:4)
오류가 발생합니다. 로컬 앱이 문제없이 잘 작동하기 때문에 이상합니다.Heroku가 내 프래그먼트를 볼 수 없습니다.
home.html을 코드 :
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<div th:replace="/fragments/head.html"></div>
<title>Personal blog - Home</title>
</head>
<body>
<div class="container">
<div th:replace="/fragments/header" th:class="row"> </div>
<div class="container">
<div class="container border w-100 post" th:each="post : ${posts}">
<div class="container">
<h1 class="display-5">
<a th:href="@{/post/} + ${post.id}" th:text="${post.title}"></a>
</h1>
<small class="text-muted" th:text="${post.creationDate}"></small>
</div>
<div class="container">
<p class="lead text-justify" th:text="${post.contents}"></p>
</div>
</div>
<nav>
<ul class="pagination justify-content-center" th:if="${lastPageIndex} gt 1">
<li class="page-item">
<a class="page-link"
th:if="${currentPage gt 1}"
th:href="@{/home/} + ${currentPage-1}">Previous</a>
</li>
<li class="page-item">
<a class="page-link" th:if="${currentPage-3} ge 1"
th:href="@{/home/} + ${currentPage-3}"
th:text="${currentPage-3}"></a>
</li>
<li class="page-item">
<a class="page-link"
th:if="${currentPage-2} ge 1"
th:href="@{/home/} + ${currentPage-2}"
th:text="${currentPage-2}"></a>
</li>
<li class="page-item">
<a class="page-link"
th:if="${currentPage-1} ge 1"
th:href="@{/home/} + ${currentPage-1}"
th:text="${currentPage-1}"></a>
</li>
<li class="page-item">
<a class="page-link" th:text="${currentPage}"></a>
</li>
<li class="page-item">
<a class="page-link"
th:if="${currentPage+1} le ${lastPageIndex}"
th:href="@{/home/} + ${currentPage+1}"
th:text="${currentPage+1}"></a>
</li>
<li class="page-item">
<a class="page-link"
th:if="${currentPage+2} le ${lastPageIndex}"
th:href="@{/home/} + ${currentPage+2}"
th:text="${currentPage+2}"></a>
</li>
<li class="page-item">
<a class="page-link"
th:if="${currentPage+3} le ${lastPageIndex}"
th:href="@{/home/} + ${currentPage+3}"
th:text="${currentPage+3}"></a>
</li>
<li class="page-item">
<a class="page-link"
th:if="${currentPage} lt ${lastPageIndex}"
th:href="@{/home/} + ${currentPage+1}">Next</a>
</li>
</ul>
</nav>
</div>
<div th:replace="/fragments/footer"> </div>
</div>
</body>
</html>
Head.html 코드 :
<!DOCTYPE html>
<html lang="en"
xmlns:th="http://www.thymeleaf.org">
<head>
<div th:fragment="head">
<meta charset="UTF-8" />
<link rel="stylesheet" type="text/css" href="/css/style.css"/>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css"
integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb"
crossorigin="anonymous"/>
</div>
</head>
</html>
당신이 볼 수 있듯이, 내 Head.html는 두 번째와 CSS 파일에 대한 링크, 부트 스트랩과 하나가 포함되어 내 자신의 수정 프로그램. 로컬에서는 모든 것이 정상적으로 작동합니다. 모든보기가 완벽하게로드됩니다. 페이지를로드하고 CSS를 적용하는 데 걸리는 시간이 0.5 초 밖에되지 않지만 heroku에서는 괜찮을 것으로 생각합니다.
내 ASPP이 링크에서 볼 수 있습니다 : 내 응용 프로그램의 https://spring-personal-blog.herokuapp.com
또한 전체 코드는 GitHub의에 repository에서 사용할 수 있습니다.
두 번째로 동일한 heroku 저장소에 내 응용 프로그램을 다시 배포하면 circualr 참조로 인해 오류가 발생합니다. PasswordEncoder. 나는 이유를 모른다. 지역적으로 모든 것이 잘 작동합니다. – Gromo
귀하의 게시물을 한 번 더 읽고 PasswordEncoder 구성을 별도의 파일로 옮겼습니다. 모든 것이 잘 작동합니다. 컨트롤러의 모든 view-name 문자열 앞에'/'에 약간의 문제가 있었지만 잠시 후에 고칠 수있었습니다. 한 번 더 도움을 주셔서 대단히 감사합니다. – Gromo