@Query(value ="select new com.iaep.model.DataModel(dr.id, dr.dtcTableName,dr.title) from DataResourceEntity dr where dr.isDelete=0")
List<DataModel> selectData();
报错如下:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘conditionTitleController’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.iaep.provider.dao.IConditionTitleDao.selectCondition()!
原因:
Dao层的bean没有创建成功,原因在于,我上面写的SQL语句,使用到了DataModel.但是却并没有在该model中写任何构造函数。故而无法成功创建对象
解决:
在DataModel上添加两个注解,分别是@NoArgsConstructor 和@AllArgsConstructor,这样子,即可解决