本文主要是介绍com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.hib,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
今天用SpringDataJPA查询数据,往redis中存储时遇到这个问题,
在网页上一搜千篇一律的解决办法都是在实体类上面加上注解
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
尝试了一下,没能解决,最后发现不是加不加注解的原因,因为SpringDataJPA的getOne()
方法查询出来的是一个动态代理对象,
而我需要的是一个实体对象,所有自己在dao层写了一个查询方法,查询出对应的学生实体信息:
public interface StudentDao extends JpaRepository<Student,Integer>, JpaSpecificationExecutor<Student> {/*** 根据学生Id查询出对应学生实体信息* @param id* @return*/@Query(value = "select * from Student where id = ?1",nativeQuery = true)Student findBystuId(Integer id);
}
这篇关于com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.hib的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!