我在ClientRepository中实现此方法时遇到问题:
**public interface ClientRepository extends JpaRepository<Client,Long> {
@Query("select n from Client where n.nom like :x")
public Page<Client> chercher(@Param("x") String mc , Pageable pageable);
}**
Exeption:
启动ApplicationContext时出错。要显示条件报告,请使用&#39; debug&#39;重新运行您的应用程序。启用。
2018-05-23 10:33:32.606 ERROR 15048 --- [restartedMa enter code here
in] o.s.boot.SpringApplication:应用程序运行失败
org.springframework.beans.factory.UnsatisfiedDependencyException:使用名称&#39; maBanqueApplication创建bean时出错&#39;:通过字段&#39; clientRepository&#39;表达的不满意的依赖关系嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为&#39; clientRepository&#39;的init时出错:init方法的调用失败;嵌套异常是java.lang.IllegalArgumentException:对于方法public abstract org.springframework.data.domain.Page org.sid.Dao.ClientRepository.chercherClient(java.lang.String,org.springframework.data.domain)的查询,验证失败。分页)! 在org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor $ AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:587)〜[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] 在org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91)〜[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
答案 0 :(得分:1)
您的查询错误:
@Query("select n from Client where n.nom like :x") // You select `n` from no where
将其更改为
@Query("select n from Client n where n.nom like :x")