解决问题:Failed to convert from type [java.lang.Object[]] to type

报错信息:org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.Object[]] to type

出现该错误的原因是因为在当前的***Repository中,查询了其他的实体.

public interface InvoiceRepository extends JpaRepository<Invoice,String>{
	
	@Query(value = "select * from invoice where user_id=?1", nativeQuery = true)
	List<Invoice> findInvoiceAll(String userId);

}

每个实体都应有各自对应的***Repository,实体要与数据库表中字段相对应, 请仔细检查。

个人出现该问题的原因是继承的JpaRepository<Invoice,String>没有改成相应的实体。

改好之后, 就不会报错。

在实体中也要加入@Entity 注解。

改好即可。


版权声明:本文为Soulmate_Min原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。