Spring Boot의 Template Engine으로 어떤 것을 사용하느냐에 따라 확장자가 달라진다.
예를 들어 Thymeleaf를 이용할 경우, .html란 확장자를 가진 파일이 템플릿으로 사용되는 반면, Freemarker를 이용할 경우 .ftl란 확장자 파일이 템플릿으로 사용된다.
템플릿 파일이 위와 같은 확장자 규칙을 제대로 따르지 않을 경우, 제대로 파일을 찾을 수 없기 때문에 아래와 같이 페이지 렌더링이 제대로 이뤄지지 않는 오류가 발생하게 된다.
1
2
3
4
5
6
7
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Mon Jul 25 18:34:27 KST 2016
There was an unexpected error (type=Internal Server Error, status=500).
Circular view path [home]: would dispatch back to the current handler URL [/home] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
이 때는 확장자를 각 엔진에 맞게 변경해 주면 해당 오류가 해결된다.
Spring Data JPA 사용 시 JSON 변환 가능한 도메인 클래스 이슈
Spring Boot에서 Spring Data JPA을 이용하기 위해 도메인 클래스를 구현한 후, REST API 구현을 하던 중이었다. REST API에서 JSON 객체를 반환하려는데 아래와 같은 오류를 띄우며 도메인 객체가 Serialize 되지 않았다.
1
2
3
4
5
6
7
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Mon Jul 25 18:25:28 KST 2016
There was an unexpected error (type=Internal Server Error, status=500).
Could not write content: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: net.spherez.metis.domain.UserEntity_$$_jvst5f1_6["handler"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: net.spherez.metis.domain.UserEntity_$$_jvst5f1_6["handler"])
알고보니 Spring Boot에서 내부적으로 설정된 값들과 충돌이 나면서 생기는 문제인 듯 했다. 이 경우 문제가 발생하는 도메인 객체에 아래와 같은 어노테이션을 달아주니 일단 해결이 됐다.