记录 @Query 报错Validation failed for query for method public abstract

代码

 
  

当查询只想要两个返回参数的时候报错

 

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'articleTest': Unsatisfied dependency expressed through field 'articleService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'articleServiceImpl': Unsatisfied dependency expressed through field 'baseRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'articleRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract 

原因是因为jpa 这样查询默认返回时对象 当然对象中只有对应查询的这两个参数

要想List 格式返回 只需要 这样既可

开启本机查询 这样就不会有问题了

你可能感兴趣的:(问题记录)