서버 관련/docker

[Spring, Docker] local 에서는 되는데 docker 에 이미지 배포하면 안 됨? +) 도커와 로컬의 thymeleaf 경로가 다르게 간주되었음.

배고파요 2024. 8. 6. 22:59
728x90

 

📍 문제의 코드

@GetMapping("/search")
public String mapPlaceSearch(){
    return "/place/search"; 
    // return "place/search";  로 변경하면 로컬, 도커 둘다 잘 됨.
}
  • 로컬에서는 잘 작동하는 데, 같은 것을 도커에 올렸더니 작동을 안함. 
  • 나오는 오류는 
    • org.thymeleaf.exceptions.TemplateInputException: Error resolving template [/place/search]
    • 타임리프 템플릿에서 에러가 났다고 한다.
    • 더보기
      ERROR 1 --- [mimi] [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.thymeleaf.exceptions.TemplateInputException: Error resolving template [/place/search], template might not exist or might not be accessible by any of the configured Template Resolvers] with root cause

      org.thymeleaf.exceptions.TemplateInputException: Error resolving template [/place/search], template might not exist or might not be accessible by any of the configured Template Resolvers
      at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869) ~[thymeleaf-3.1.2.RELEASE.jar!/:3.1.2.RELEASE]
  • 문제의 이유는 타임리프의 경로 처리와 spring 의 경로 처리가 다를 수 있기 때문.
  • 그렇다면, 로컬에서는 잘 됬던 이유? 
    • 정확히는 잘 모르겠지만, 캐시로 인한 것이 아닐까 함.
      • 다르게 설정한 부분은 없었기 때문에, 설정으로 인한 문제는 아니였을 것이라 생각함.

 

📍 chatgpt 가 알려줌.

더보기
  • 경로 처리 관련 문제.

 

 

 

  • 로컬에서는 문제가 없던 이유

 


출처 : 

 

 

 


개발 공부를 위한 블로그 입니다. 

오류가 있다면 댓글로 알려주세요! 

감사합니다.

728x90