본문 바로가기
사이드 프로젝트/To-do 캘린더 프로젝트

Spring boot 프로젝트 AWS 배포 오류 해결기록(5)

by Baley 2022. 9. 3.

1. 문제점: [THYMELEAF] Exception processing template - Error resolving template

캡처 1

배포 스크립트인 deploy.sh를 nohup으로 실행하는 데 까지는 성공했으나 뷰 페이지를 불러오는 데에 타임리프 에러가 발생하였다.

 

2. 원인

template might not exist ot might not be accesible by any of the configured Template Resolvers

타임리프의 Template Resolver가 view에 사용된 html의 디렉토리 인식을 하지 못 해 발생하는 에러이다. IDE에서는 정상적으로 작동하지만 bootJar를 통해 배포한 경우, 배포한 페이지에서 이런 에러가 발생한다고 한다.

컨트롤러에서 view의 이름을 리턴해줄 때 리턴되는 view의 이름 앞에 '/'를 함께 입력했을 경우 '/'만 삭제해주면 된다. 예를 들어 return 되어야 할 view 페이지의 이름과 확장자가 home.html인데 컨트롤러에서 /home을 리턴한다면 간단하게 '/'를 삭제하고 home만 입력해주면 된다.

 

3. 해결

나의 경우는 이렇게 컨트롤러로 return 해주는 값의 문제가 아니라 Thymeleaf의 replace 속성을 이용하다가 에러가 난 것이었다.

캡처 2

replace되는 html 자원의 경로가 '/'를 포함하고 있다. 따라서 '/'만 지워주는 것으로 해결 가능했다.

캡처 3

html 경로 앞에 '/'를 지워주니 정상 작동한다.

 


# 참고:

https://findmypiece.tistory.com/199

 

Thymeleaf 에서 html 자원을 찾지 못할 때

06-16 15:44:07.790 [XNIO-11 task-127] ERROR org.thymeleaf.TemplateEngine - [THYMELEAF][XNIO-11 task-127] Exception processing template "comment/remove": An error happened during template parsing (te..

findmypiece.tistory.com

https://devkingdom.tistory.com/149

 

[Debugging] Thymeleaf 사용할 때, org.thymeleaf.exceptions.TemplateInputException: Error resolving template 에러 발생할

다른 노트북 (윈도우 10) 환경에서 개발할 때는 이상없이 잘 html을 찾아가던 소스코드가, 새로운 환경에서 돌리니.. 아래와 같은 Exception이 발생했다. 추측 상 컨트롤러에서 '/' 을 붙여서 절대경로

devkingdom.tistory.com

https://bigphu.tistory.com/94

 

[Spring Boot/Thymeleaf] Exception processing template

스프링 부트로 프로젝트 작업중에 파싱에러가 발생했다. ide 사용시에는 정상이었으나 운영배포 때문에 jar package 테스트를 위하여 cmd 창에서 java -jar 로 실행하니 에러가 발생하였다. 총 두가지

bigphu.tistory.com

댓글