<html><body><h1>Whitelabel Error Page</h1><p>This application has no explicit mapping for /error, so you are seeing this as a fallback.</p><div id='created'>Tue Jan 16 16:27:34 GMT+08:00 2018</div><div>There was an unexpected error (type=Internal Server Error, status=500).</div><div>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: java.util.HashMap["key"]->cn.ac.iscas.gz.cloud.business.domain.Canteen_$$_jvst4f2_14["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: java.util.HashMap["key"]->cn.ac.iscas.gz.cloud.business.domain.Canteen_$$_jvst4f2_14["handler"])</div></body></html>解决思路是,在实体上面新增如下注解:
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
如果是导致无线递归问题的话,可以用下面:
@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler","historyArcticlesLinkMapping"})
添加如下注解,使得所有类同时生效
@Bean
public ObjectMapper myMapper() {
return new ObjectMapper().disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
}